@untangle-code/cli 0.0.0-stage → 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 (571) hide show
  1. package/LICENSE +661 -0
  2. package/NOTICE +90 -0
  3. package/README.md +451 -2
  4. package/THIRD_PARTY_LICENSES.md +152 -0
  5. package/dist/cli/args.d.ts +48 -0
  6. package/dist/cli/args.d.ts.map +1 -0
  7. package/dist/cli/args.js +167 -0
  8. package/dist/cli/args.js.map +1 -0
  9. package/dist/cli/command.d.ts +69 -0
  10. package/dist/cli/command.d.ts.map +1 -0
  11. package/dist/cli/command.js +82 -0
  12. package/dist/cli/command.js.map +1 -0
  13. package/dist/cli/deadline.d.ts +33 -0
  14. package/dist/cli/deadline.d.ts.map +1 -0
  15. package/dist/cli/deadline.js +49 -0
  16. package/dist/cli/deadline.js.map +1 -0
  17. package/dist/cli/embedder-deadline.d.ts +72 -0
  18. package/dist/cli/embedder-deadline.d.ts.map +1 -0
  19. package/dist/cli/embedder-deadline.js +117 -0
  20. package/dist/cli/embedder-deadline.js.map +1 -0
  21. package/dist/cli/exit.d.ts +71 -0
  22. package/dist/cli/exit.d.ts.map +1 -0
  23. package/dist/cli/exit.js +81 -0
  24. package/dist/cli/exit.js.map +1 -0
  25. package/dist/cli/graphs.d.ts +65 -0
  26. package/dist/cli/graphs.d.ts.map +1 -0
  27. package/dist/cli/graphs.js +108 -0
  28. package/dist/cli/graphs.js.map +1 -0
  29. package/dist/cli/index-freshness.d.ts +13 -0
  30. package/dist/cli/index-freshness.d.ts.map +1 -0
  31. package/dist/cli/index-freshness.js +226 -0
  32. package/dist/cli/index-freshness.js.map +1 -0
  33. package/dist/cli/index-refresh.d.ts +10 -0
  34. package/dist/cli/index-refresh.d.ts.map +1 -0
  35. package/dist/cli/index-refresh.js +76 -0
  36. package/dist/cli/index-refresh.js.map +1 -0
  37. package/dist/cli/index-state.d.ts +184 -0
  38. package/dist/cli/index-state.d.ts.map +1 -0
  39. package/dist/cli/index-state.js +852 -0
  40. package/dist/cli/index-state.js.map +1 -0
  41. package/dist/cli/io.d.ts +29 -0
  42. package/dist/cli/io.d.ts.map +1 -0
  43. package/dist/cli/io.js +42 -0
  44. package/dist/cli/io.js.map +1 -0
  45. package/dist/cli/language-support.d.ts +77 -0
  46. package/dist/cli/language-support.d.ts.map +1 -0
  47. package/dist/cli/language-support.js +152 -0
  48. package/dist/cli/language-support.js.map +1 -0
  49. package/dist/cli/renewing-lease.d.ts +26 -0
  50. package/dist/cli/renewing-lease.d.ts.map +1 -0
  51. package/dist/cli/renewing-lease.js +102 -0
  52. package/dist/cli/renewing-lease.js.map +1 -0
  53. package/dist/cli/search-graph-enrichment.d.ts +16 -0
  54. package/dist/cli/search-graph-enrichment.d.ts.map +1 -0
  55. package/dist/cli/search-graph-enrichment.js +428 -0
  56. package/dist/cli/search-graph-enrichment.js.map +1 -0
  57. package/dist/cli/system.d.ts +34 -0
  58. package/dist/cli/system.d.ts.map +1 -0
  59. package/dist/cli/system.js +89 -0
  60. package/dist/cli/system.js.map +1 -0
  61. package/dist/cli/vector-store-policy.d.ts +116 -0
  62. package/dist/cli/vector-store-policy.d.ts.map +1 -0
  63. package/dist/cli/vector-store-policy.js +160 -0
  64. package/dist/cli/vector-store-policy.js.map +1 -0
  65. package/dist/cli/version.d.ts +3 -0
  66. package/dist/cli/version.d.ts.map +1 -0
  67. package/dist/cli/version.js +3 -0
  68. package/dist/cli/version.js.map +1 -0
  69. package/dist/cli/workspace.d.ts +105 -0
  70. package/dist/cli/workspace.d.ts.map +1 -0
  71. package/dist/cli/workspace.js +215 -0
  72. package/dist/cli/workspace.js.map +1 -0
  73. package/dist/commands/complexity.d.ts +72 -0
  74. package/dist/commands/complexity.d.ts.map +1 -0
  75. package/dist/commands/complexity.js +580 -0
  76. package/dist/commands/complexity.js.map +1 -0
  77. package/dist/commands/doctor.d.ts +66 -0
  78. package/dist/commands/doctor.d.ts.map +1 -0
  79. package/dist/commands/doctor.js +764 -0
  80. package/dist/commands/doctor.js.map +1 -0
  81. package/dist/commands/doctor.languages.d.ts +37 -0
  82. package/dist/commands/doctor.languages.d.ts.map +1 -0
  83. package/dist/commands/doctor.languages.js +143 -0
  84. package/dist/commands/doctor.languages.js.map +1 -0
  85. package/dist/commands/doctor.storage.d.ts +17 -0
  86. package/dist/commands/doctor.storage.d.ts.map +1 -0
  87. package/dist/commands/doctor.storage.js +91 -0
  88. package/dist/commands/doctor.storage.js.map +1 -0
  89. package/dist/commands/extensions/add.d.ts +10 -0
  90. package/dist/commands/extensions/add.d.ts.map +1 -0
  91. package/dist/commands/extensions/add.js +213 -0
  92. package/dist/commands/extensions/add.js.map +1 -0
  93. package/dist/commands/extensions/configure.d.ts +5 -0
  94. package/dist/commands/extensions/configure.d.ts.map +1 -0
  95. package/dist/commands/extensions/configure.js +58 -0
  96. package/dist/commands/extensions/configure.js.map +1 -0
  97. package/dist/commands/extensions/container.d.ts +15 -0
  98. package/dist/commands/extensions/container.d.ts.map +1 -0
  99. package/dist/commands/extensions/container.js +135 -0
  100. package/dist/commands/extensions/container.js.map +1 -0
  101. package/dist/commands/extensions/context.d.ts +37 -0
  102. package/dist/commands/extensions/context.d.ts.map +1 -0
  103. package/dist/commands/extensions/context.js +72 -0
  104. package/dist/commands/extensions/context.js.map +1 -0
  105. package/dist/commands/extensions/enable.d.ts +6 -0
  106. package/dist/commands/extensions/enable.d.ts.map +1 -0
  107. package/dist/commands/extensions/enable.js +180 -0
  108. package/dist/commands/extensions/enable.js.map +1 -0
  109. package/dist/commands/extensions/environment.d.ts +74 -0
  110. package/dist/commands/extensions/environment.d.ts.map +1 -0
  111. package/dist/commands/extensions/environment.js +168 -0
  112. package/dist/commands/extensions/environment.js.map +1 -0
  113. package/dist/commands/extensions/feature-scan.d.ts +48 -0
  114. package/dist/commands/extensions/feature-scan.d.ts.map +1 -0
  115. package/dist/commands/extensions/feature-scan.js +156 -0
  116. package/dist/commands/extensions/feature-scan.js.map +1 -0
  117. package/dist/commands/extensions/invoke.d.ts +60 -0
  118. package/dist/commands/extensions/invoke.d.ts.map +1 -0
  119. package/dist/commands/extensions/invoke.js +275 -0
  120. package/dist/commands/extensions/invoke.js.map +1 -0
  121. package/dist/commands/extensions/list.d.ts +5 -0
  122. package/dist/commands/extensions/list.d.ts.map +1 -0
  123. package/dist/commands/extensions/list.js +125 -0
  124. package/dist/commands/extensions/list.js.map +1 -0
  125. package/dist/commands/extensions/logs.d.ts +5 -0
  126. package/dist/commands/extensions/logs.d.ts.map +1 -0
  127. package/dist/commands/extensions/logs.js +74 -0
  128. package/dist/commands/extensions/logs.js.map +1 -0
  129. package/dist/commands/extensions/provision.d.ts +36 -0
  130. package/dist/commands/extensions/provision.d.ts.map +1 -0
  131. package/dist/commands/extensions/provision.js +137 -0
  132. package/dist/commands/extensions/provision.js.map +1 -0
  133. package/dist/commands/extensions/remove.d.ts +5 -0
  134. package/dist/commands/extensions/remove.d.ts.map +1 -0
  135. package/dist/commands/extensions/remove.js +77 -0
  136. package/dist/commands/extensions/remove.js.map +1 -0
  137. package/dist/commands/extensions/render.d.ts +16 -0
  138. package/dist/commands/extensions/render.d.ts.map +1 -0
  139. package/dist/commands/extensions/render.js +25 -0
  140. package/dist/commands/extensions/render.js.map +1 -0
  141. package/dist/commands/extensions/run.d.ts +30 -0
  142. package/dist/commands/extensions/run.d.ts.map +1 -0
  143. package/dist/commands/extensions/run.js +292 -0
  144. package/dist/commands/extensions/run.js.map +1 -0
  145. package/dist/commands/extensions/secret-store.d.ts +15 -0
  146. package/dist/commands/extensions/secret-store.d.ts.map +1 -0
  147. package/dist/commands/extensions/secret-store.js +164 -0
  148. package/dist/commands/extensions/secret-store.js.map +1 -0
  149. package/dist/commands/extensions/setup.d.ts +17 -0
  150. package/dist/commands/extensions/setup.d.ts.map +1 -0
  151. package/dist/commands/extensions/setup.js +94 -0
  152. package/dist/commands/extensions/setup.js.map +1 -0
  153. package/dist/commands/extensions/source.d.ts +47 -0
  154. package/dist/commands/extensions/source.d.ts.map +1 -0
  155. package/dist/commands/extensions/source.js +142 -0
  156. package/dist/commands/extensions/source.js.map +1 -0
  157. package/dist/commands/extensions/state.d.ts +62 -0
  158. package/dist/commands/extensions/state.d.ts.map +1 -0
  159. package/dist/commands/extensions/state.js +177 -0
  160. package/dist/commands/extensions/state.js.map +1 -0
  161. package/dist/commands/extensions/status.d.ts +9 -0
  162. package/dist/commands/extensions/status.d.ts.map +1 -0
  163. package/dist/commands/extensions/status.js +239 -0
  164. package/dist/commands/extensions/status.js.map +1 -0
  165. package/dist/commands/extensions.d.ts +3 -0
  166. package/dist/commands/extensions.d.ts.map +1 -0
  167. package/dist/commands/extensions.js +223 -0
  168. package/dist/commands/extensions.js.map +1 -0
  169. package/dist/commands/flow/index.d.ts +3 -0
  170. package/dist/commands/flow/index.d.ts.map +1 -0
  171. package/dist/commands/flow/index.js +295 -0
  172. package/dist/commands/flow/index.js.map +1 -0
  173. package/dist/commands/flow/limits.d.ts +12 -0
  174. package/dist/commands/flow/limits.d.ts.map +1 -0
  175. package/dist/commands/flow/limits.js +13 -0
  176. package/dist/commands/flow/limits.js.map +1 -0
  177. package/dist/commands/flow/output.d.ts +8 -0
  178. package/dist/commands/flow/output.d.ts.map +1 -0
  179. package/dist/commands/flow/output.js +11 -0
  180. package/dist/commands/flow/output.js.map +1 -0
  181. package/dist/commands/flow/render.d.ts +51 -0
  182. package/dist/commands/flow/render.d.ts.map +1 -0
  183. package/dist/commands/flow/render.js +220 -0
  184. package/dist/commands/flow/render.js.map +1 -0
  185. package/dist/commands/flow/select.d.ts +31 -0
  186. package/dist/commands/flow/select.d.ts.map +1 -0
  187. package/dist/commands/flow/select.js +62 -0
  188. package/dist/commands/flow/select.js.map +1 -0
  189. package/dist/commands/graph/boundaries-input.d.ts +26 -0
  190. package/dist/commands/graph/boundaries-input.d.ts.map +1 -0
  191. package/dist/commands/graph/boundaries-input.js +54 -0
  192. package/dist/commands/graph/boundaries-input.js.map +1 -0
  193. package/dist/commands/graph/boundaries.d.ts +4 -0
  194. package/dist/commands/graph/boundaries.d.ts.map +1 -0
  195. package/dist/commands/graph/boundaries.js +141 -0
  196. package/dist/commands/graph/boundaries.js.map +1 -0
  197. package/dist/commands/graph/bounds.d.ts +16 -0
  198. package/dist/commands/graph/bounds.d.ts.map +1 -0
  199. package/dist/commands/graph/bounds.js +22 -0
  200. package/dist/commands/graph/bounds.js.map +1 -0
  201. package/dist/commands/graph/category-clusters.d.ts +20 -0
  202. package/dist/commands/graph/category-clusters.d.ts.map +1 -0
  203. package/dist/commands/graph/category-clusters.js +158 -0
  204. package/dist/commands/graph/category-clusters.js.map +1 -0
  205. package/dist/commands/graph/feature-3d.d.ts +22 -0
  206. package/dist/commands/graph/feature-3d.d.ts.map +1 -0
  207. package/dist/commands/graph/feature-3d.js +114 -0
  208. package/dist/commands/graph/feature-3d.js.map +1 -0
  209. package/dist/commands/graph/feature-clusters.d.ts +17 -0
  210. package/dist/commands/graph/feature-clusters.d.ts.map +1 -0
  211. package/dist/commands/graph/feature-clusters.js +94 -0
  212. package/dist/commands/graph/feature-clusters.js.map +1 -0
  213. package/dist/commands/graph/feature-html.d.ts +26 -0
  214. package/dist/commands/graph/feature-html.d.ts.map +1 -0
  215. package/dist/commands/graph/feature-html.js +314 -0
  216. package/dist/commands/graph/feature-html.js.map +1 -0
  217. package/dist/commands/graph/feature-map.d.ts +31 -0
  218. package/dist/commands/graph/feature-map.d.ts.map +1 -0
  219. package/dist/commands/graph/feature-map.js +217 -0
  220. package/dist/commands/graph/feature-map.js.map +1 -0
  221. package/dist/commands/graph/feature-model.d.ts +55 -0
  222. package/dist/commands/graph/feature-model.d.ts.map +1 -0
  223. package/dist/commands/graph/feature-model.js +167 -0
  224. package/dist/commands/graph/feature-model.js.map +1 -0
  225. package/dist/commands/graph/feature-untangle-motion.d.ts +33 -0
  226. package/dist/commands/graph/feature-untangle-motion.d.ts.map +1 -0
  227. package/dist/commands/graph/feature-untangle-motion.js +155 -0
  228. package/dist/commands/graph/feature-untangle-motion.js.map +1 -0
  229. package/dist/commands/graph/index.d.ts +3 -0
  230. package/dist/commands/graph/index.d.ts.map +1 -0
  231. package/dist/commands/graph/index.js +414 -0
  232. package/dist/commands/graph/index.js.map +1 -0
  233. package/dist/commands/graph/render.d.ts +63 -0
  234. package/dist/commands/graph/render.d.ts.map +1 -0
  235. package/dist/commands/graph/render.js +352 -0
  236. package/dist/commands/graph/render.js.map +1 -0
  237. package/dist/commands/graph/select.d.ts +34 -0
  238. package/dist/commands/graph/select.d.ts.map +1 -0
  239. package/dist/commands/graph/select.js +55 -0
  240. package/dist/commands/graph/select.js.map +1 -0
  241. package/dist/commands/index/index.d.ts +6 -0
  242. package/dist/commands/index/index.d.ts.map +1 -0
  243. package/dist/commands/index/index.js +461 -0
  244. package/dist/commands/index/index.js.map +1 -0
  245. package/dist/commands/index/render.d.ts +53 -0
  246. package/dist/commands/index/render.d.ts.map +1 -0
  247. package/dist/commands/index/render.js +205 -0
  248. package/dist/commands/index/render.js.map +1 -0
  249. package/dist/commands/index/target.d.ts +34 -0
  250. package/dist/commands/index/target.d.ts.map +1 -0
  251. package/dist/commands/index/target.js +97 -0
  252. package/dist/commands/index/target.js.map +1 -0
  253. package/dist/commands/index-watch.d.ts +30 -0
  254. package/dist/commands/index-watch.d.ts.map +1 -0
  255. package/dist/commands/index-watch.js +138 -0
  256. package/dist/commands/index-watch.js.map +1 -0
  257. package/dist/commands/init/command.d.ts +25 -0
  258. package/dist/commands/init/command.d.ts.map +1 -0
  259. package/dist/commands/init/command.js +198 -0
  260. package/dist/commands/init/command.js.map +1 -0
  261. package/dist/commands/init/config-draft.d.ts +48 -0
  262. package/dist/commands/init/config-draft.d.ts.map +1 -0
  263. package/dist/commands/init/config-draft.js +201 -0
  264. package/dist/commands/init/config-draft.js.map +1 -0
  265. package/dist/commands/init/diff.d.ts +33 -0
  266. package/dist/commands/init/diff.d.ts.map +1 -0
  267. package/dist/commands/init/diff.js +109 -0
  268. package/dist/commands/init/diff.js.map +1 -0
  269. package/dist/commands/init/http-probe.d.ts +26 -0
  270. package/dist/commands/init/http-probe.d.ts.map +1 -0
  271. package/dist/commands/init/http-probe.js +144 -0
  272. package/dist/commands/init/http-probe.js.map +1 -0
  273. package/dist/commands/init/ignore-rules.d.ts +70 -0
  274. package/dist/commands/init/ignore-rules.d.ts.map +1 -0
  275. package/dist/commands/init/ignore-rules.js +146 -0
  276. package/dist/commands/init/ignore-rules.js.map +1 -0
  277. package/dist/commands/init/index.d.ts +33 -0
  278. package/dist/commands/init/index.d.ts.map +1 -0
  279. package/dist/commands/init/index.js +32 -0
  280. package/dist/commands/init/index.js.map +1 -0
  281. package/dist/commands/init/integrations-apply.d.ts +50 -0
  282. package/dist/commands/init/integrations-apply.d.ts.map +1 -0
  283. package/dist/commands/init/integrations-apply.js +452 -0
  284. package/dist/commands/init/integrations-apply.js.map +1 -0
  285. package/dist/commands/init/integrations-plan.d.ts +68 -0
  286. package/dist/commands/init/integrations-plan.d.ts.map +1 -0
  287. package/dist/commands/init/integrations-plan.js +515 -0
  288. package/dist/commands/init/integrations-plan.js.map +1 -0
  289. package/dist/commands/init/integrations.d.ts +5 -0
  290. package/dist/commands/init/integrations.d.ts.map +1 -0
  291. package/dist/commands/init/integrations.js +4 -0
  292. package/dist/commands/init/integrations.js.map +1 -0
  293. package/dist/commands/init/languages.d.ts +55 -0
  294. package/dist/commands/init/languages.d.ts.map +1 -0
  295. package/dist/commands/init/languages.js +245 -0
  296. package/dist/commands/init/languages.js.map +1 -0
  297. package/dist/commands/init/product-context.d.ts +63 -0
  298. package/dist/commands/init/product-context.d.ts.map +1 -0
  299. package/dist/commands/init/product-context.js +390 -0
  300. package/dist/commands/init/product-context.js.map +1 -0
  301. package/dist/commands/init/render.d.ts +38 -0
  302. package/dist/commands/init/render.d.ts.map +1 -0
  303. package/dist/commands/init/render.js +501 -0
  304. package/dist/commands/init/render.js.map +1 -0
  305. package/dist/commands/init/report.d.ts +24 -0
  306. package/dist/commands/init/report.d.ts.map +1 -0
  307. package/dist/commands/init/report.js +163 -0
  308. package/dist/commands/init/report.js.map +1 -0
  309. package/dist/commands/init/run.d.ts +71 -0
  310. package/dist/commands/init/run.d.ts.map +1 -0
  311. package/dist/commands/init/run.js +253 -0
  312. package/dist/commands/init/run.js.map +1 -0
  313. package/dist/commands/init/services.d.ts +82 -0
  314. package/dist/commands/init/services.d.ts.map +1 -0
  315. package/dist/commands/init/services.js +209 -0
  316. package/dist/commands/init/services.js.map +1 -0
  317. package/dist/commands/init/storage.d.ts +8 -0
  318. package/dist/commands/init/storage.d.ts.map +1 -0
  319. package/dist/commands/init/storage.js +102 -0
  320. package/dist/commands/init/storage.js.map +1 -0
  321. package/dist/commands/init/toml.d.ts +65 -0
  322. package/dist/commands/init/toml.d.ts.map +1 -0
  323. package/dist/commands/init/toml.js +159 -0
  324. package/dist/commands/init/toml.js.map +1 -0
  325. package/dist/commands/init/topology.d.ts +54 -0
  326. package/dist/commands/init/topology.d.ts.map +1 -0
  327. package/dist/commands/init/topology.js +146 -0
  328. package/dist/commands/init/topology.js.map +1 -0
  329. package/dist/commands/init/types.d.ts +334 -0
  330. package/dist/commands/init/types.d.ts.map +1 -0
  331. package/dist/commands/init/types.js +31 -0
  332. package/dist/commands/init/types.js.map +1 -0
  333. package/dist/commands/init/wizard-terminal.d.ts +36 -0
  334. package/dist/commands/init/wizard-terminal.d.ts.map +1 -0
  335. package/dist/commands/init/wizard-terminal.js +163 -0
  336. package/dist/commands/init/wizard-terminal.js.map +1 -0
  337. package/dist/commands/init/wizard.d.ts +25 -0
  338. package/dist/commands/init/wizard.d.ts.map +1 -0
  339. package/dist/commands/init/wizard.js +358 -0
  340. package/dist/commands/init/wizard.js.map +1 -0
  341. package/dist/commands/mcp.d.ts +4 -0
  342. package/dist/commands/mcp.d.ts.map +1 -0
  343. package/dist/commands/mcp.js +111 -0
  344. package/dist/commands/mcp.js.map +1 -0
  345. package/dist/commands/product-test-runner.d.ts +4 -0
  346. package/dist/commands/product-test-runner.d.ts.map +1 -0
  347. package/dist/commands/product-test-runner.js +85 -0
  348. package/dist/commands/product-test-runner.js.map +1 -0
  349. package/dist/commands/product.d.ts +16 -0
  350. package/dist/commands/product.d.ts.map +1 -0
  351. package/dist/commands/product.js +262 -0
  352. package/dist/commands/product.js.map +1 -0
  353. package/dist/commands/query.d.ts +114 -0
  354. package/dist/commands/query.d.ts.map +1 -0
  355. package/dist/commands/query.js +783 -0
  356. package/dist/commands/query.js.map +1 -0
  357. package/dist/commands/scan.d.ts +10 -0
  358. package/dist/commands/scan.d.ts.map +1 -0
  359. package/dist/commands/scan.js +302 -0
  360. package/dist/commands/scan.js.map +1 -0
  361. package/dist/commands/sdd.d.ts +24 -0
  362. package/dist/commands/sdd.d.ts.map +1 -0
  363. package/dist/commands/sdd.js +195 -0
  364. package/dist/commands/sdd.js.map +1 -0
  365. package/dist/commands/unavailable.d.ts +40 -0
  366. package/dist/commands/unavailable.d.ts.map +1 -0
  367. package/dist/commands/unavailable.js +73 -0
  368. package/dist/commands/unavailable.js.map +1 -0
  369. package/dist/commands/watch/analyze.d.ts +69 -0
  370. package/dist/commands/watch/analyze.d.ts.map +1 -0
  371. package/dist/commands/watch/analyze.js +402 -0
  372. package/dist/commands/watch/analyze.js.map +1 -0
  373. package/dist/commands/watch/cli.d.ts +8 -0
  374. package/dist/commands/watch/cli.d.ts.map +1 -0
  375. package/dist/commands/watch/cli.js +97 -0
  376. package/dist/commands/watch/cli.js.map +1 -0
  377. package/dist/commands/watch/delta.d.ts +46 -0
  378. package/dist/commands/watch/delta.d.ts.map +1 -0
  379. package/dist/commands/watch/delta.js +170 -0
  380. package/dist/commands/watch/delta.js.map +1 -0
  381. package/dist/commands/watch/events.d.ts +214 -0
  382. package/dist/commands/watch/events.d.ts.map +1 -0
  383. package/dist/commands/watch/events.js +13 -0
  384. package/dist/commands/watch/events.js.map +1 -0
  385. package/dist/commands/watch/index.d.ts +19 -0
  386. package/dist/commands/watch/index.d.ts.map +1 -0
  387. package/dist/commands/watch/index.js +15 -0
  388. package/dist/commands/watch/index.js.map +1 -0
  389. package/dist/commands/watch/options.d.ts +43 -0
  390. package/dist/commands/watch/options.d.ts.map +1 -0
  391. package/dist/commands/watch/options.js +193 -0
  392. package/dist/commands/watch/options.js.map +1 -0
  393. package/dist/commands/watch/render.d.ts +26 -0
  394. package/dist/commands/watch/render.d.ts.map +1 -0
  395. package/dist/commands/watch/render.js +175 -0
  396. package/dist/commands/watch/render.js.map +1 -0
  397. package/dist/commands/watch/run.d.ts +14 -0
  398. package/dist/commands/watch/run.d.ts.map +1 -0
  399. package/dist/commands/watch/run.js +460 -0
  400. package/dist/commands/watch/run.js.map +1 -0
  401. package/dist/commands/watch/runtime.d.ts +67 -0
  402. package/dist/commands/watch/runtime.d.ts.map +1 -0
  403. package/dist/commands/watch/runtime.js +149 -0
  404. package/dist/commands/watch/runtime.js.map +1 -0
  405. package/dist/commands/watch-command.d.ts +3 -0
  406. package/dist/commands/watch-command.d.ts.map +1 -0
  407. package/dist/commands/watch-command.js +273 -0
  408. package/dist/commands/watch-command.js.map +1 -0
  409. package/dist/entry-point.d.ts +11 -0
  410. package/dist/entry-point.d.ts.map +1 -0
  411. package/dist/entry-point.js +65 -0
  412. package/dist/entry-point.js.map +1 -0
  413. package/dist/index.d.ts +38 -0
  414. package/dist/index.d.ts.map +1 -0
  415. package/dist/index.js +245 -0
  416. package/dist/index.js.map +1 -0
  417. package/dist/mcp/boundaries-schema.d.ts +262 -0
  418. package/dist/mcp/boundaries-schema.d.ts.map +1 -0
  419. package/dist/mcp/boundaries-schema.js +183 -0
  420. package/dist/mcp/boundaries-schema.js.map +1 -0
  421. package/dist/mcp/default-runtime.d.ts +16 -0
  422. package/dist/mcp/default-runtime.d.ts.map +1 -0
  423. package/dist/mcp/default-runtime.js +718 -0
  424. package/dist/mcp/default-runtime.js.map +1 -0
  425. package/dist/mcp/envelope.d.ts +13 -0
  426. package/dist/mcp/envelope.d.ts.map +1 -0
  427. package/dist/mcp/envelope.js +29 -0
  428. package/dist/mcp/envelope.js.map +1 -0
  429. package/dist/mcp/index.d.ts +8 -0
  430. package/dist/mcp/index.d.ts.map +1 -0
  431. package/dist/mcp/index.js +8 -0
  432. package/dist/mcp/index.js.map +1 -0
  433. package/dist/mcp/output-schemas.d.ts +5928 -0
  434. package/dist/mcp/output-schemas.d.ts.map +1 -0
  435. package/dist/mcp/output-schemas.js +2814 -0
  436. package/dist/mcp/output-schemas.js.map +1 -0
  437. package/dist/mcp/path-sandbox.d.ts +35 -0
  438. package/dist/mcp/path-sandbox.d.ts.map +1 -0
  439. package/dist/mcp/path-sandbox.js +128 -0
  440. package/dist/mcp/path-sandbox.js.map +1 -0
  441. package/dist/mcp/server.d.ts +155 -0
  442. package/dist/mcp/server.d.ts.map +1 -0
  443. package/dist/mcp/server.js +257 -0
  444. package/dist/mcp/server.js.map +1 -0
  445. package/dist/mcp/stdio.d.ts +20 -0
  446. package/dist/mcp/stdio.d.ts.map +1 -0
  447. package/dist/mcp/stdio.js +71 -0
  448. package/dist/mcp/stdio.js.map +1 -0
  449. package/dist/mcp/tools.d.ts +355 -0
  450. package/dist/mcp/tools.d.ts.map +1 -0
  451. package/dist/mcp/tools.js +319 -0
  452. package/dist/mcp/tools.js.map +1 -0
  453. package/dist/mcp/types.d.ts +15 -0
  454. package/dist/mcp/types.d.ts.map +1 -0
  455. package/dist/mcp/types.js +45 -0
  456. package/dist/mcp/types.js.map +1 -0
  457. package/package.json +99 -3
  458. package/src/cli/args.ts +231 -0
  459. package/src/cli/command.ts +146 -0
  460. package/src/cli/deadline.ts +56 -0
  461. package/src/cli/embedder-deadline.ts +187 -0
  462. package/src/cli/exit.ts +94 -0
  463. package/src/cli/graphs.ts +191 -0
  464. package/src/cli/index-freshness.ts +303 -0
  465. package/src/cli/index-refresh.ts +125 -0
  466. package/src/cli/index-state.ts +1217 -0
  467. package/src/cli/io.ts +56 -0
  468. package/src/cli/language-support.ts +203 -0
  469. package/src/cli/renewing-lease.ts +121 -0
  470. package/src/cli/search-graph-enrichment.ts +639 -0
  471. package/src/cli/system.ts +94 -0
  472. package/src/cli/vector-store-policy.ts +213 -0
  473. package/src/cli/version.ts +2 -0
  474. package/src/cli/workspace.ts +324 -0
  475. package/src/commands/complexity.ts +776 -0
  476. package/src/commands/doctor.languages.ts +187 -0
  477. package/src/commands/doctor.storage.ts +124 -0
  478. package/src/commands/doctor.ts +946 -0
  479. package/src/commands/extensions/add.ts +312 -0
  480. package/src/commands/extensions/configure.ts +82 -0
  481. package/src/commands/extensions/container.ts +209 -0
  482. package/src/commands/extensions/context.ts +109 -0
  483. package/src/commands/extensions/enable.ts +237 -0
  484. package/src/commands/extensions/environment.ts +218 -0
  485. package/src/commands/extensions/feature-scan.ts +232 -0
  486. package/src/commands/extensions/invoke.ts +368 -0
  487. package/src/commands/extensions/list.ts +158 -0
  488. package/src/commands/extensions/logs.ts +104 -0
  489. package/src/commands/extensions/provision.ts +206 -0
  490. package/src/commands/extensions/remove.ts +110 -0
  491. package/src/commands/extensions/render.ts +32 -0
  492. package/src/commands/extensions/run.ts +386 -0
  493. package/src/commands/extensions/secret-store.ts +223 -0
  494. package/src/commands/extensions/setup.ts +140 -0
  495. package/src/commands/extensions/source.ts +189 -0
  496. package/src/commands/extensions/state.ts +252 -0
  497. package/src/commands/extensions/status.ts +320 -0
  498. package/src/commands/extensions.ts +280 -0
  499. package/src/commands/flow/index.ts +402 -0
  500. package/src/commands/flow/limits.ts +14 -0
  501. package/src/commands/flow/output.ts +16 -0
  502. package/src/commands/flow/render.ts +318 -0
  503. package/src/commands/flow/select.ts +101 -0
  504. package/src/commands/graph/boundaries-input.ts +63 -0
  505. package/src/commands/graph/boundaries.ts +182 -0
  506. package/src/commands/graph/bounds.ts +25 -0
  507. package/src/commands/graph/category-clusters.ts +194 -0
  508. package/src/commands/graph/feature-3d.ts +141 -0
  509. package/src/commands/graph/feature-clusters.ts +125 -0
  510. package/src/commands/graph/feature-html.ts +336 -0
  511. package/src/commands/graph/feature-map.ts +270 -0
  512. package/src/commands/graph/feature-model.ts +234 -0
  513. package/src/commands/graph/feature-untangle-motion.ts +192 -0
  514. package/src/commands/graph/index.ts +562 -0
  515. package/src/commands/graph/render.ts +503 -0
  516. package/src/commands/graph/select.ts +77 -0
  517. package/src/commands/index/index.ts +595 -0
  518. package/src/commands/index/render.ts +325 -0
  519. package/src/commands/index/target.ts +136 -0
  520. package/src/commands/index-watch.ts +206 -0
  521. package/src/commands/init/command.ts +238 -0
  522. package/src/commands/init/config-draft.ts +235 -0
  523. package/src/commands/init/diff.ts +117 -0
  524. package/src/commands/init/http-probe.ts +150 -0
  525. package/src/commands/init/ignore-rules.ts +170 -0
  526. package/src/commands/init/index.ts +63 -0
  527. package/src/commands/init/integrations-apply.ts +618 -0
  528. package/src/commands/init/integrations-plan.ts +634 -0
  529. package/src/commands/init/integrations.ts +8 -0
  530. package/src/commands/init/languages.ts +320 -0
  531. package/src/commands/init/product-context.ts +576 -0
  532. package/src/commands/init/render.ts +598 -0
  533. package/src/commands/init/report.ts +204 -0
  534. package/src/commands/init/run.ts +349 -0
  535. package/src/commands/init/services.ts +271 -0
  536. package/src/commands/init/storage.ts +136 -0
  537. package/src/commands/init/toml.ts +174 -0
  538. package/src/commands/init/topology.ts +192 -0
  539. package/src/commands/init/types.ts +366 -0
  540. package/src/commands/init/wizard-terminal.ts +206 -0
  541. package/src/commands/init/wizard.ts +450 -0
  542. package/src/commands/mcp.ts +123 -0
  543. package/src/commands/product-test-runner.ts +80 -0
  544. package/src/commands/product.ts +331 -0
  545. package/src/commands/query.ts +1032 -0
  546. package/src/commands/scan.ts +360 -0
  547. package/src/commands/sdd.ts +243 -0
  548. package/src/commands/unavailable.ts +92 -0
  549. package/src/commands/watch/README.md +160 -0
  550. package/src/commands/watch/analyze.ts +600 -0
  551. package/src/commands/watch/cli.ts +108 -0
  552. package/src/commands/watch/delta.ts +186 -0
  553. package/src/commands/watch/events.ts +235 -0
  554. package/src/commands/watch/index.ts +53 -0
  555. package/src/commands/watch/options.ts +234 -0
  556. package/src/commands/watch/render.ts +240 -0
  557. package/src/commands/watch/run.ts +553 -0
  558. package/src/commands/watch/runtime.ts +167 -0
  559. package/src/commands/watch-command.ts +294 -0
  560. package/src/entry-point.ts +67 -0
  561. package/src/index.ts +291 -0
  562. package/src/mcp/boundaries-schema.ts +193 -0
  563. package/src/mcp/default-runtime.ts +1034 -0
  564. package/src/mcp/envelope.ts +57 -0
  565. package/src/mcp/index.ts +28 -0
  566. package/src/mcp/output-schemas.ts +3071 -0
  567. package/src/mcp/path-sandbox.ts +156 -0
  568. package/src/mcp/server.ts +358 -0
  569. package/src/mcp/stdio.ts +92 -0
  570. package/src/mcp/tools.ts +563 -0
  571. package/src/mcp/types.ts +66 -0
@@ -0,0 +1,600 @@
1
+ /**
2
+ * Die Messung einer Datei — die Stelle, an der parser-registry, chunker und
3
+ * complexity zu EINER Messung zusammenlaufen.
4
+ *
5
+ * Der Weg einer Datei durch dieses Modul:
6
+ *
7
+ * Inhalt
8
+ * -> `ParserRegistry.getAdapterForPath` (parser-registry)
9
+ * -> `adapter.parse` / `extractChunks` / `extractSymbols` / `extractCalls`
10
+ * / `computeComplexity`
11
+ * -> `chunkFile` (chunker) .... semantische Ladung
12
+ * -> `withUniqueScopeIds` (complexity) .... eindeutige metrics_scope_id
13
+ * -> `computeStructural` / `computeCyclomatic` / `computeCognitive`
14
+ * -> `checkScopeTreeInvariants` + `checkAllScopeCoverage`
15
+ * -> `aggregateScopeTree` / `selectScopeEntries` (scope-aggregate)
16
+ *
17
+ * ## Die vier Metriken (vision.md §1b)
18
+ *
19
+ * DREI davon sind Scope-Metriken und werden ueber `metrics_scope_id`
20
+ * aggregiert, ohne Doppelzaehlung — die ausgewiesene Zahl ist die Lesart
21
+ * `"execution_unit"` aus `packages/complexity/src/scope-aggregate.ts`: jede
22
+ * aeusserste Ausfuehrungseinheit genau einmal, verschachtelte Closures darin
23
+ * enthalten.
24
+ *
25
+ * - `cognitive` — `computeCognitive` ueber die IR (`untangle-cognitive-v1`,
26
+ * spec.md §16.4).
27
+ * - `cyclomatic` — `computeCyclomatic(...).extended` (spec.md §16.3).
28
+ * - `structural` — `parameter_count + return_count + exit_point_count` aus
29
+ * `computeStructural` (spec.md §16.5). WARUM GENAU DIESE DREI: die Lesarten
30
+ * der Scope-Aggregation SUMMIEREN. Summierbar und ueberschneidungsfrei
31
+ * zerlegbar sind von den strukturellen Metriken nur die zaehlenden; `sloc`
32
+ * und `max_nesting` sind es nicht (`sloc` eines Elternscopes enthaelt die
33
+ * Zeilen seiner Kinder, `max_nesting` ist ein Maximum, keine Summe) — sie
34
+ * waeren als Summe entweder doppelt gezaehlt oder bedeutungslos. Die drei
35
+ * gewaehlten zaehlen die strukturelle Oberflaeche eines Scopes: wie viele
36
+ * Groessen hineingehen und wie viele Wege hinausfuehren.
37
+ *
38
+ * DIE VIERTE ist bewusst KEINE Scope-Metrik:
39
+ *
40
+ * - `semantic` — die semantische Ladung der Datei: die Summe der
41
+ * Token-Schaetzungen ueber alle Chunks, die der chunker fuer die Datei
42
+ * erzeugt (`CodeChunkDraft.tokenEstimate`, architecture.md §14.4).
43
+ * Sie beantwortet "wie viel Kontext muss geladen werden, um diese Datei zu
44
+ * verstehen" und faellt genau dann, wenn dieselbe Aussage mit weniger
45
+ * Bedeutungseinheiten auskommt (vision.md §1d). Sie wird ueber CHUNKS
46
+ * summiert, nicht ueber Scopes; deshalb traegt sie die Lesart
47
+ * `"file_chunks"` und niemals `"execution_unit"`.
48
+ *
49
+ * OFFEN GESAGT: spec.md §16 kennt keine Metrik "semantisch". Dies ist eine
50
+ * untangle-lokale Lesart mit ausgewiesener Herkunft, keine
51
+ * Spezifikationsmetrik — sie wird als solche benannt und nicht als §16-Wert
52
+ * ausgegeben.
53
+ *
54
+ * ## Warum eine Messung scheitern DARF
55
+ *
56
+ * Jeder Fehlschlag endet als `SkipLedgerEntryV1` mit Grund und Detailtext,
57
+ * nie als stiller `continue` (E4). Insbesondere geht eine Datei mit
58
+ * `parseQuality !== "complete"` NICHT in die Zahlen ein: ein beschaedigter
59
+ * Syntaxbaum liefert nachweislich falsche Scope-Grenzen (siehe
60
+ * `scripts/complexity-report.mjs`, Kopfkommentar Punkt 5). Sie erscheint
61
+ * stattdessen als `unanalyzed`-Ereignis im Strom.
62
+ */
63
+ import { chunkFile } from "@untangle-code/chunker";
64
+ import {
65
+ buildSymbolIR,
66
+ checkAllScopeCoverage,
67
+ checkScopeTreeInvariants,
68
+ computeCognitive,
69
+ computeCyclomatic,
70
+ computeStructural,
71
+ containsRange,
72
+ selectScopeEntries,
73
+ selectSymbolFacts,
74
+ withUniqueScopeIds,
75
+ type ScopeInvariantViolationV1,
76
+ type ScopeMetricNodeV1,
77
+ } from "@untangle-code/complexity";
78
+ import {
79
+ buildSkipLedgerEntry,
80
+ classifyAdapterFailure,
81
+ classifyTextFormat,
82
+ compareCodepoints,
83
+ COGNITIVE_ALGORITHM_ID,
84
+ METRICS_VERSION,
85
+ sha256Hex,
86
+ type ComplexityFacts,
87
+ type ParseQuality,
88
+ type ParserRegistry,
89
+ type SkipLedgerEntryV1,
90
+ } from "@untangle-code/domain";
91
+
92
+ import { METRIC_KEYS, zeroMetricValues, type MetricKey, type MetricValues } from "./events.js";
93
+
94
+ /**
95
+ * Scope-Arten, die eine eigene Ausfuehrungseinheit sind.
96
+ * `SymbolScopeFact.kind` ist ein adapterspezifischer String;
97
+ * `packages/complexity` kennt bewusst keine Sprach-Taxonomie, die Zuordnung
98
+ * trifft deshalb der Aufrufer (siehe `ScopeMetricNodeV1.executionUnit`).
99
+ * Identisch zu `scripts/complexity-report.mjs`, damit Waechter und Report
100
+ * dieselbe Zahl meinen.
101
+ */
102
+ const EXECUTION_UNIT_KINDS = new Set(["function", "method", "constructor", "lambda"]);
103
+
104
+ /** Ein gemessener Scope, so wie ihn der Waechter zwischen zwei Staenden vergleicht. */
105
+ export interface ScopeReadingV1 {
106
+ /** `metrics_scope_id` (spec.md §16.10) — eindeutig INNERHALB dieser Messung. */
107
+ metricsScopeId: string;
108
+ /**
109
+ * Schluessel fuer den Vergleich ZWISCHEN zwei Messungen.
110
+ *
111
+ * WARUM NICHT `metricsScopeId`: `withUniqueScopeIds` bildet die eindeutige
112
+ * Id aus der Byte-Range des Scopes. Das ist innerhalb einer Messung genau
113
+ * richtig und ueber zwei Messungen hinweg unbrauchbar — schon eine
114
+ * eingefuegte Zeile verschiebt jede Range und damit jede Id, und der
115
+ * Waechter meldete dann fuer jede Aenderung "alle Scopes weg, alle Scopes
116
+ * neu". Der Vergleichsschluessel ist deshalb die urspruengliche
117
+ * Adapter-Id (qualifizierter Name plus Ordinal) plus ein Ordinal fuer den
118
+ * Fall, dass der Adapter dieselbe Id mehrfach vergeben hat.
119
+ */
120
+ matchKey: string;
121
+ label: string;
122
+ kind: string;
123
+ line: number;
124
+ /** Wert je Metrik in der Lesart `"execution_unit"`; nur ausgewaehlte Scopes haben einen. */
125
+ values: MetricValues;
126
+ /** True, wenn dieser Scope in der Lesart `"execution_unit"` ein Summand ist. */
127
+ selected: boolean;
128
+ }
129
+
130
+ /** Das Messergebnis EINER Datei. */
131
+ export interface FileReadingV1 {
132
+ path: string;
133
+ languageId: string;
134
+ contentHash: string;
135
+ parseQuality: ParseQuality;
136
+ totals: MetricValues;
137
+ scopes: ScopeReadingV1[];
138
+ /** Anzahl der Chunks, in die der chunker die Datei zerlegt. */
139
+ chunkUnits: number;
140
+ /** Wie viele davon `symbol_fragment` sind: ein Symbol passte nicht in einen Chunk. */
141
+ chunkFragments: number;
142
+ scopeCount: number;
143
+ scopeIdCollisions: number;
144
+ nodeKindFallbacks: number;
145
+ /** Einschraenkungen dieser Messung im Klartext; leer heisst: keine. */
146
+ notes: string[];
147
+ }
148
+
149
+ export type AnalysisOutcomeV1 =
150
+ { ok: true; reading: FileReadingV1 } | { ok: false; entry: SkipLedgerEntryV1 };
151
+
152
+ export interface FileAnalyzerOptions {
153
+ registry: ParserRegistry;
154
+ repoId: string;
155
+ refId: string;
156
+ workspaceId: string;
157
+ /** Menschenlesbares Ref-Label fuer den Chunker-Kopf (spec.md §8.6). */
158
+ refName: string;
159
+ repoLabel: string;
160
+ }
161
+
162
+ /**
163
+ * Baut den Analysator EINMAL (die Grammatiken laden faul beim ersten
164
+ * `parse()`) und liefert eine reine Funktion `analyze(path, content)`.
165
+ */
166
+ export function createFileAnalyzer(
167
+ options: FileAnalyzerOptions,
168
+ ): (relativePath: string, content: string) => AnalysisOutcomeV1 {
169
+ return (relativePath, content) => analyzeFile(options, relativePath, content);
170
+ }
171
+
172
+ function skip(
173
+ relativePath: string,
174
+ reason: SkipLedgerEntryV1["reason"],
175
+ stage: SkipLedgerEntryV1["stage"],
176
+ detail: string,
177
+ recoverable: boolean,
178
+ ): AnalysisOutcomeV1 {
179
+ return {
180
+ ok: false,
181
+ entry: buildSkipLedgerEntry({
182
+ stage,
183
+ subjectKind: "file",
184
+ path: relativePath,
185
+ reason,
186
+ detail,
187
+ recoverable,
188
+ }),
189
+ };
190
+ }
191
+
192
+ function analyzeFile(
193
+ options: FileAnalyzerOptions,
194
+ relativePath: string,
195
+ content: string,
196
+ ): AnalysisOutcomeV1 {
197
+ const adapter = options.registry.getAdapterForPath(relativePath);
198
+ if (adapter === null) {
199
+ return skip(
200
+ relativePath,
201
+ "unsupported_language",
202
+ "parse",
203
+ `No language adapter is registered for "${relativePath}"; the file contributes to no ` +
204
+ `complexity measurement and its change produces no delta.`,
205
+ false,
206
+ );
207
+ }
208
+
209
+ if (classifyTextFormat(relativePath) === "generated") {
210
+ return skip(
211
+ relativePath,
212
+ "generated_content",
213
+ "parse",
214
+ `"${relativePath}" is generated content (such as a lockfile). It contains no ` +
215
+ `authored statement; its change produces no delta.`,
216
+ false,
217
+ );
218
+ }
219
+
220
+ // WP-217: Stufe `text` hat keine Scopes und keine Entscheidungspunkte. Die
221
+ // vier Metriken dieses Moduls (cognitive, cyclomatic, structural, semantic)
222
+ // sind Code-Metriken; sie auf ein Dokument anzuwenden ergaebe vier Nullen,
223
+ // die wie eine Messung aussehen. Der Watcher sagt deshalb, was er NICHT
224
+ // gerechnet hat — samt der Stelle, an der es gerechnet wird.
225
+ if (adapter.supportLevel === "text") {
226
+ const prose = classifyTextFormat(relativePath) === "prose";
227
+ return skip(
228
+ relativePath,
229
+ "no_metric_defined",
230
+ "parse",
231
+ prose
232
+ ? `"${relativePath}" is prose (tier "text"). Prose metrics are defined and ` +
233
+ `computed by "untangle complexity --prose"; this watcher path does not compute ` +
234
+ `them yet. Cognitive, cyclomatic and structural metrics would show zeros ` +
235
+ `that could be mistaken for measurements; this note is emitted ` +
236
+ `instead of a delta.`
237
+ : `"${relativePath}" is structured configuration (tier "text"): supported ` +
238
+ `for chunks and search, but without control flow or section structure. ` +
239
+ `Neither a code metric nor a prose metric is defined for it.`,
240
+ false,
241
+ );
242
+ }
243
+
244
+ const contentHash = sha256Hex(content);
245
+ const source = {
246
+ fileId: relativePath,
247
+ repoId: options.repoId,
248
+ refId: options.refId,
249
+ path: relativePath,
250
+ languageId: adapter.languageId,
251
+ content,
252
+ contentHash,
253
+ sizeBytes: Buffer.byteLength(content, "utf8"),
254
+ };
255
+
256
+ let parseResult;
257
+ try {
258
+ parseResult = adapter.parse(source);
259
+ } catch (error) {
260
+ // WP-216: benannter Grund statt durchgereichtem Ausnahmetext (E4).
261
+ const failure = classifyAdapterFailure(error, { sizeBytes: source.sizeBytes });
262
+ return skip(
263
+ relativePath,
264
+ failure.reason,
265
+ "parse",
266
+ `Adapter "${adapter.languageId}": ${failure.detail}`,
267
+ failure.recoverable,
268
+ );
269
+ }
270
+
271
+ if (parseResult.ast === null) {
272
+ return skip(
273
+ relativePath,
274
+ "parse_failed",
275
+ "parse",
276
+ `parseQuality="${parseResult.parseQuality}" has no syntax tree; no facts can be derived.`,
277
+ false,
278
+ );
279
+ }
280
+
281
+ if (parseResult.parseQuality !== "complete") {
282
+ const damagedBytes = parseResult.diagnostics.reduce(
283
+ (sum, diagnostic) => sum + (diagnostic.range.endByte - diagnostic.range.startByte),
284
+ 0,
285
+ );
286
+ return skip(
287
+ relativePath,
288
+ "parse_failed",
289
+ "parse",
290
+ `parseQuality="${parseResult.parseQuality}": ${String(parseResult.errorNodeCount)} ` +
291
+ `error nodes and ${String(parseResult.missingNodeCount)} missing nodes ` +
292
+ `(${String(damagedBytes)} of ${String(source.sizeBytes)} bytes fall below ` +
293
+ `error nodes). Scope boundaries and decision points would be unreliable; ` +
294
+ `the file therefore contributes to no measurement rather than silently distorting deltas.`,
295
+ true,
296
+ );
297
+ }
298
+
299
+ const ast = parseResult.ast;
300
+ let rawFacts: ComplexityFacts;
301
+ let regions;
302
+ let symbols;
303
+ let rawCalls;
304
+ try {
305
+ regions = adapter.extractChunks(ast);
306
+ symbols = adapter.extractSymbols(ast);
307
+ rawCalls = adapter.extractCalls(ast);
308
+ rawFacts = adapter.computeComplexity(ast);
309
+ } catch (error) {
310
+ return skip(
311
+ relativePath,
312
+ "parse_failed",
313
+ "parse",
314
+ `The adapter for "${adapter.languageId}" failed while evaluating the syntax tree: ` +
315
+ `geworfen: ${messageOf(error)}`,
316
+ false,
317
+ );
318
+ }
319
+
320
+ // --- semantische Ladung: der chunker ---------------------------------
321
+ let chunkResult;
322
+ try {
323
+ chunkResult = chunkFile({
324
+ identity: {
325
+ workspaceId: options.workspaceId,
326
+ repoId: options.repoId,
327
+ refId: options.refId,
328
+ fileId: relativePath,
329
+ filePath: relativePath,
330
+ languageId: adapter.languageId,
331
+ },
332
+ content,
333
+ parseResult,
334
+ regions,
335
+ symbols,
336
+ config: {
337
+ preparedText: {
338
+ documentPrefix: "search_document:",
339
+ repoLabel: options.repoLabel,
340
+ refName: options.refName,
341
+ },
342
+ },
343
+ });
344
+ } catch (error) {
345
+ return skip(
346
+ relativePath,
347
+ "parse_failed",
348
+ "chunk",
349
+ `The chunker failed: ${messageOf(error)}`,
350
+ false,
351
+ );
352
+ }
353
+
354
+ const notes: string[] = parseResult.diagnostics
355
+ .filter((diagnostic) => diagnostic.code === "analysis_scope_limited")
356
+ .map((diagnostic) => diagnostic.message);
357
+ for (const degradation of chunkResult.degradations) {
358
+ notes.push(
359
+ `Chunker fallback (${degradation.reason}, strategy "${degradation.strategy}"): ` +
360
+ degradation.detail,
361
+ );
362
+ }
363
+
364
+ const semantic = chunkResult.drafts.reduce((sum, draft) => sum + draft.tokenEstimate, 0);
365
+ const chunkFragments = chunkResult.drafts.filter(
366
+ (draft) => draft.chunkKind === "symbol_fragment",
367
+ ).length;
368
+
369
+ // --- Scope-Metriken: complexity ---------------------------------------
370
+ const repaired = withUniqueScopeIds(rawFacts, rawCalls, relativePath);
371
+ const facts = repaired.facts;
372
+ const calls = repaired.calls;
373
+
374
+ if (repaired.collisions.length > 0) {
375
+ const scopes = repaired.collisions.reduce((sum, c) => sum + c.scopeCount, 0);
376
+ notes.push(
377
+ `${String(repaired.collisions.length)} ambiguous adapter scope ID(s) across ` +
378
+ `${String(scopes)} scopes remapped to unique metrics_scope_id values (WP-82).`,
379
+ );
380
+ }
381
+ if (repaired.nodeKindsAttributedByFallback > 0) {
382
+ notes.push(
383
+ `${String(repaired.nodeKindsAttributedByFallback)} NodeKindFact(s) without SourceRange ` +
384
+ `could only be assigned through a fallback; this file's structural metric ` +
385
+ `therefore has only approximate scope precision.`,
386
+ );
387
+ }
388
+
389
+ const subtreeIds = subtreeIdsOf(facts);
390
+ const perMetricNodes: Record<Exclude<MetricKey, "semantic">, ScopeMetricNodeV1[]> = {
391
+ structural: [],
392
+ cyclomatic: [],
393
+ cognitive: [],
394
+ };
395
+ const meta = new Map<string, { matchKey: string; label: string; kind: string; line: number }>();
396
+ const matchOrdinals = new Map<string, number>();
397
+
398
+ for (const scope of facts.symbolScopes) {
399
+ const id = scope.symbolScopeId;
400
+ const ownFacts = selectSymbolFacts(facts, id);
401
+ const ids = subtreeIds.get(id) ?? new Set([id]);
402
+ const shared = {
403
+ metricsScopeId: id,
404
+ executionUnit: EXECUTION_UNIT_KINDS.has(scope.kind),
405
+ sloc: Math.max(1, scope.range.endLine - scope.range.startLine + 1),
406
+ ...(scope.parentScopeId === undefined ? {} : { parentScopeId: scope.parentScopeId }),
407
+ };
408
+
409
+ // cognitive: derselbe Calculator, einmal auf den ungefilterten Datei-Facts
410
+ // (der IR-Builder zieht alle Nachfahren hinein) und einmal auf den
411
+ // eigenen Facts des Scopes.
412
+ const inclusiveIr = buildSymbolIR(facts, id, { calls });
413
+ const ownIr = buildSymbolIR(ownFacts, id, { calls });
414
+ perMetricNodes.cognitive.push({
415
+ ...shared,
416
+ inclusiveValue:
417
+ inclusiveIr === undefined ? 0 : computeCognitive(inclusiveIr, COGNITIVE_ALGORITHM_ID).value,
418
+ selfValue: ownIr === undefined ? 0 : computeCognitive(ownIr, COGNITIVE_ALGORITHM_ID).value,
419
+ });
420
+
421
+ // cyclomatic: Entscheidungspunkte des Scopes UND aller Nachfahren
422
+ // (Byte-Containment), damit "inclusive" dasselbe bedeutet wie bei cognitive.
423
+ const subtreeDecisionFacts: ComplexityFacts = {
424
+ ...facts,
425
+ decisions: facts.decisions.filter((d) => containsRange(scope.range, d.range)),
426
+ };
427
+ perMetricNodes.cyclomatic.push({
428
+ ...shared,
429
+ inclusiveValue: computeCyclomatic(
430
+ subtreeDecisionFacts,
431
+ scope.range.startLine,
432
+ METRICS_VERSION,
433
+ ).extended,
434
+ selfValue: computeCyclomatic(ownFacts, scope.range.startLine, METRICS_VERSION).extended,
435
+ });
436
+
437
+ // structural: die zaehlenden Metriken aus §16.5. `NodeKindFact`s tragen
438
+ // eine `symbolScopeId`, also ist die Zerlegung ueber die Scope-Ids des
439
+ // Teilbaums exakt: inclusive = self + Summe der Kinder, per Konstruktion.
440
+ const subtreeNodeKindFacts: ComplexityFacts = {
441
+ ...facts,
442
+ nodeKinds: facts.nodeKinds.filter((fact) => ids.has(fact.symbolScopeId)),
443
+ };
444
+ perMetricNodes.structural.push({
445
+ ...shared,
446
+ inclusiveValue: structuralLoad(subtreeNodeKindFacts, content, scope.range),
447
+ selfValue: structuralLoad(ownFacts, content, scope.range),
448
+ });
449
+
450
+ const adapterId = repaired.originalScopeIds.get(id) ?? id;
451
+ const ordinal = matchOrdinals.get(adapterId) ?? 0;
452
+ matchOrdinals.set(adapterId, ordinal + 1);
453
+ meta.set(id, {
454
+ matchKey: `${adapterId}#${String(ordinal)}`,
455
+ label: scope.qualifiedName || scope.name || `(${scope.kind})`,
456
+ kind: scope.kind,
457
+ line: scope.range.startLine,
458
+ });
459
+ }
460
+
461
+ // --- Invarianten: erst pruefen, dann summieren ------------------------
462
+ const violations: ScopeInvariantViolationV1[] = [];
463
+ for (const metric of ["structural", "cyclomatic", "cognitive"] as const) {
464
+ const nodes = perMetricNodes[metric];
465
+ violations.push(...checkScopeTreeInvariants(nodes, treeOptionsFor(metric)));
466
+ violations.push(...checkAllScopeCoverage(nodes));
467
+ }
468
+ if (violations.length > 0) {
469
+ const first = violations
470
+ .slice()
471
+ .sort((a, b) => compareCodepoints(a.metricsScopeId, b.metricsScopeId))
472
+ .slice(0, 3)
473
+ .map((v) => `${v.code} @ ${v.metricsScopeId}: ${v.detail}`)
474
+ .join(" | ");
475
+ return skip(
476
+ relativePath,
477
+ "parse_failed",
478
+ "parse",
479
+ `${String(violations.length)} invariant violation(s) in the scope tree; a total ` +
480
+ `over an inconsistent tree would be meaningless. First: ${first}`,
481
+ false,
482
+ );
483
+ }
484
+
485
+ const totals: Record<MetricKey, number> = { ...zeroMetricValues(), semantic };
486
+ const selectedValues = new Map<string, Record<MetricKey, number>>();
487
+ for (const metric of ["structural", "cyclomatic", "cognitive"] as const) {
488
+ const entries = selectScopeEntries(perMetricNodes[metric], "execution_unit");
489
+ let sum = 0;
490
+ for (const entry of entries) {
491
+ sum += entry.value;
492
+ const bucket = selectedValues.get(entry.metricsScopeId) ?? { ...zeroMetricValues() };
493
+ bucket[metric] = entry.value;
494
+ selectedValues.set(entry.metricsScopeId, bucket);
495
+ }
496
+ totals[metric] = sum;
497
+ }
498
+
499
+ const scopes: ScopeReadingV1[] = [];
500
+ for (const [id, info] of meta) {
501
+ const values = selectedValues.get(id);
502
+ scopes.push({
503
+ metricsScopeId: id,
504
+ matchKey: info.matchKey,
505
+ label: info.label,
506
+ kind: info.kind,
507
+ line: info.line,
508
+ values: values ?? zeroMetricValues(),
509
+ selected: values !== undefined,
510
+ });
511
+ }
512
+ scopes.sort((a, b) => compareCodepoints(a.matchKey, b.matchKey));
513
+
514
+ return {
515
+ ok: true,
516
+ reading: {
517
+ path: relativePath,
518
+ languageId: adapter.languageId,
519
+ contentHash,
520
+ parseQuality: parseResult.parseQuality,
521
+ totals,
522
+ scopes,
523
+ chunkUnits: chunkResult.drafts.length,
524
+ chunkFragments,
525
+ scopeCount: facts.symbolScopes.length,
526
+ scopeIdCollisions: repaired.collisions.length,
527
+ nodeKindFallbacks: repaired.nodeKindsAttributedByFallback,
528
+ notes,
529
+ },
530
+ };
531
+ }
532
+
533
+ /**
534
+ * `perScopeBase` je Metrik. `computeCyclomatic` legt IMMER den
535
+ * `M = 1 + decision_points`-Sockel an; ohne diese Angabe meldete die
536
+ * Eltern/Kind-Pruefung Scheinverstoesse, sobald ein Scope mehr als ein Kind
537
+ * hat (siehe `ScopeTreeOptions.perScopeBase`).
538
+ */
539
+ function treeOptionsFor(metric: "structural" | "cyclomatic" | "cognitive"): {
540
+ perScopeBase: number;
541
+ } {
542
+ return { perScopeBase: metric === "cyclomatic" ? 1 : 0 };
543
+ }
544
+
545
+ /**
546
+ * Die strukturelle Last eines Scopes: `parameter_count + return_count +
547
+ * exit_point_count` aus `computeStructural` (spec.md §16.5) — siehe
548
+ * Modul-Doku fuer die Begruendung, warum genau diese drei.
549
+ */
550
+ function structuralLoad(
551
+ facts: ComplexityFacts,
552
+ content: string,
553
+ range: { startLine: number; endLine: number; startByte: number; endByte: number },
554
+ ): number {
555
+ const metrics = computeStructural(facts, content, range).metrics;
556
+ return (
557
+ (metrics["parameter_count"] ?? 0) +
558
+ (metrics["return_count"] ?? 0) +
559
+ (metrics["exit_point_count"] ?? 0)
560
+ );
561
+ }
562
+
563
+ /**
564
+ * Fuer jeden Scope die Menge seiner eigenen Id plus aller Nachfahren-Ids.
565
+ * Die Elternkette ist nach `checkScopeTreeInvariants` zyklenfrei; hier wird
566
+ * trotzdem gegen Zyklen abgesichert, weil diese Funktion VOR der Pruefung
567
+ * laeuft.
568
+ */
569
+ function subtreeIdsOf(facts: ComplexityFacts): Map<string, Set<string>> {
570
+ const children = new Map<string, string[]>();
571
+ const all: string[] = [];
572
+ for (const scope of facts.symbolScopes) {
573
+ all.push(scope.symbolScopeId);
574
+ const parent = scope.parentScopeId;
575
+ if (parent === undefined) continue;
576
+ const bucket = children.get(parent) ?? [];
577
+ bucket.push(scope.symbolScopeId);
578
+ children.set(parent, bucket);
579
+ }
580
+ const result = new Map<string, Set<string>>();
581
+ for (const id of all) {
582
+ const collected = new Set<string>();
583
+ const stack = [id];
584
+ while (stack.length > 0) {
585
+ const current = stack.pop() as string;
586
+ if (collected.has(current)) continue;
587
+ collected.add(current);
588
+ for (const child of children.get(current) ?? []) stack.push(child);
589
+ }
590
+ result.set(id, collected);
591
+ }
592
+ return result;
593
+ }
594
+
595
+ function messageOf(error: unknown): string {
596
+ return error instanceof Error ? error.message : String(error);
597
+ }
598
+
599
+ /** Die Metrik-Reihenfolge, an die sich jede Darstellung haelt. */
600
+ export const ORDERED_METRICS: readonly MetricKey[] = METRIC_KEYS;
@@ -0,0 +1,108 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Der ausfuehrbare Einstiegspunkt des Waechters.
4
+ *
5
+ * Er liegt bewusst INNERHALB von `src/commands/watch/`: das Kommando bringt
6
+ * seine eigene Verdrahtung mit (Uhr, Zufall, Signale, Standardausgabe) und
7
+ * haengt an keiner Datei ausserhalb dieses Verzeichnisses. Damit ist der
8
+ * Waechter fuer sich allein baubar und vorfuehrbar, waehrend der uebrige
9
+ * CLI-Rahmen (WP-124) noch entsteht.
10
+ *
11
+ * Zwei Aufrufwege, beide gleichwertig:
12
+ * node dist/index.js watch [OPTIONEN] (ueber den CLI-Rahmen)
13
+ * node dist/commands/watch/cli.js [OPTIONEN] (direkt)
14
+ */
15
+ import { hostname } from "node:os";
16
+
17
+ import { parseWatchArgs, WATCH_USAGE } from "./options.js";
18
+ import { runWatch } from "./run.js";
19
+ import { CryptoRandom, SystemClock } from "./runtime.js";
20
+
21
+ /**
22
+ * Fuehrt `untangle watch` aus und liefert den Exit-Code.
23
+ *
24
+ * 0 = sauber beendet, 1 = Betriebsfehler, 2 = Aufruffehler.
25
+ */
26
+ export async function runWatchCli(argv: readonly string[]): Promise<number> {
27
+ // The opt-in index mode needs the full composition root. A URL import keeps
28
+ // build:watch's original complexity-only dependency graph independent.
29
+ if (
30
+ argv.some((arg) =>
31
+ ["--index", "--no-index", "--repo", "--ref", "--embedder"].includes(arg.split("=")[0] ?? ""),
32
+ )
33
+ ) {
34
+ const runtime = (await import(new URL("../../index.js", import.meta.url).href)) as {
35
+ run(args: readonly string[], options: { signal: AbortSignal }): Promise<number>;
36
+ };
37
+ const controller = new AbortController();
38
+ const abort = (): void => controller.abort();
39
+ process.on("SIGINT", abort);
40
+ process.on("SIGTERM", abort);
41
+ try {
42
+ return await runtime.run(["watch", ...argv], { signal: controller.signal });
43
+ } finally {
44
+ process.off("SIGINT", abort);
45
+ process.off("SIGTERM", abort);
46
+ }
47
+ }
48
+ const parsed = parseWatchArgs(argv, {
49
+ cwd: process.cwd(),
50
+ isTty: process.stdout.isTTY === true,
51
+ noColorEnv: process.env["NO_COLOR"],
52
+ });
53
+ if (!parsed.ok) {
54
+ process.stderr.write(`untangle watch: ${parsed.message}\n\n${WATCH_USAGE}\n`);
55
+ return 2;
56
+ }
57
+ if (parsed.options.help) {
58
+ process.stdout.write(`${WATCH_USAGE}\n`);
59
+ return 0;
60
+ }
61
+
62
+ return runWatch(parsed.options, {
63
+ clock: new SystemClock(),
64
+ random: new CryptoRandom(),
65
+ stdout: (chunk) => {
66
+ process.stdout.write(chunk);
67
+ },
68
+ stderr: (chunk) => {
69
+ process.stderr.write(chunk);
70
+ },
71
+ host: hostname(),
72
+ /**
73
+ * SIGINT/SIGTERM. Die Abmeldung wird zurueckgegeben, damit `runWatch`
74
+ * den Griff loesen kann, sobald der Abbau laeuft: ein ZWEITES Strg-C
75
+ * soll dann wieder die Vorgabewirkung haben und hart beenden, statt in
76
+ * einem Waechter zu haengen, der gerade aufraeumt.
77
+ */
78
+ installSignalHandler: (handler) => {
79
+ const signals: readonly NodeJS.Signals[] = ["SIGINT", "SIGTERM"];
80
+ const listeners = signals.map((signal) => {
81
+ const listener = (): void => {
82
+ handler(signal);
83
+ };
84
+ process.on(signal, listener);
85
+ return { signal, listener };
86
+ });
87
+ return () => {
88
+ for (const { signal, listener } of listeners) process.off(signal, listener);
89
+ };
90
+ },
91
+ });
92
+ }
93
+
94
+ const isDirectInvocation =
95
+ process.argv[1] !== undefined && process.argv[1].endsWith("commands/watch/cli.js");
96
+
97
+ if (isDirectInvocation) {
98
+ runWatchCli(process.argv.slice(2))
99
+ .then((code) => {
100
+ process.exitCode = code;
101
+ })
102
+ .catch((error: unknown) => {
103
+ process.stderr.write(
104
+ `untangle watch: ${error instanceof Error ? (error.stack ?? error.message) : String(error)}\n`,
105
+ );
106
+ process.exitCode = 1;
107
+ });
108
+ }