0sec-cli 0.18.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (329) hide show
  1. package/{0sec.js → 0.js} +90 -82
  2. package/LICENSE +1 -1
  3. package/README.md +62 -46
  4. package/chunks/adapt-loop-7I57LXXR.js +18 -0
  5. package/chunks/{adgraph-JLGA6RYI.js → adgraph-AUDQTBYA.js} +5 -5
  6. package/chunks/agent/skills/frameworks/entra-id.yaml +2 -2
  7. package/chunks/agent/skills/techniques/assumption-mining.yaml +2 -2
  8. package/chunks/agent/skills/techniques/cve-poc-adaptation.yaml +2 -2
  9. package/chunks/agent/skills/techniques/entra-attack-paths.yaml +1 -1
  10. package/chunks/agent/skills/techniques/kernel-weaponization.yaml +1 -1
  11. package/chunks/agent/skills/techniques/llm-prompt-injection.yaml +2 -2
  12. package/chunks/agent/skills/techniques/npm-ecosystem.yaml +1 -1
  13. package/chunks/agent/skills/techniques/poc-verification.yaml +1 -1
  14. package/chunks/agent/skills/techniques/seedless-depth-review.yaml +20 -38
  15. package/chunks/{artifact-scraper-HQ7HLP6V.js → artifact-scraper-PYZ3RU3O.js} +6 -6
  16. package/chunks/{assumption-mining-5SNIVVDN.js → assumption-mining-MFLF43IR.js} +24 -26
  17. package/chunks/{chunk-7DQEV5QI.js → chunk-23DG5YKS.js} +4 -4
  18. package/chunks/{chunk-UR4ELX2Y.js → chunk-2GV4HQKE.js} +340 -703
  19. package/chunks/{chunk-P6WKNFWX.js → chunk-2OQOQ2FZ.js} +8 -8
  20. package/chunks/{chunk-5G3ZXFBW.js → chunk-2WNCI664.js} +3 -3
  21. package/chunks/{chunk-DW5UWPFY.js → chunk-4VGLO2YS.js} +6 -5
  22. package/chunks/{chunk-KLTNTE2Z.js → chunk-5IBCBQEH.js} +13 -14
  23. package/chunks/{chunk-N7BOUYEV.js → chunk-5MWAG3FT.js} +14 -14
  24. package/chunks/{chunk-OEFNRYI2.js → chunk-6GHSR47F.js} +3 -6
  25. package/chunks/chunk-6YNKRUMC.js +4474 -0
  26. package/chunks/{chunk-6L26OBWI.js → chunk-76KSBWOQ.js} +255 -35
  27. package/chunks/chunk-7DEHG7YT.js +2143 -0
  28. package/chunks/{chunk-AD7WXDH6.js → chunk-7UFUALR2.js} +288 -22
  29. package/chunks/{chunk-53G27VPS.js → chunk-AZ7L3HFD.js} +7 -2
  30. package/chunks/{chunk-TSK2AG6J.js → chunk-CAYANSH6.js} +173 -1757
  31. package/chunks/{chunk-SAFFWQW4.js → chunk-DKSCN2AB.js} +7 -7
  32. package/chunks/{chunk-2JCCA2JL.js → chunk-DM5C5L5D.js} +3 -3
  33. package/chunks/{chunk-RWONANDA.js → chunk-DQTNI3KY.js} +5 -5
  34. package/chunks/{chunk-5JI7L7KV.js → chunk-EGZGZFAH.js} +10036 -12938
  35. package/chunks/{chunk-6LKRLK2R.js → chunk-FHC2B7LN.js} +3 -3
  36. package/chunks/{chunk-MYVT64FN.js → chunk-GHWODZMR.js} +2 -2
  37. package/chunks/{chunk-2RMLOJVB.js → chunk-GVD6SJGH.js} +2 -2
  38. package/chunks/{chunk-SF4KZ4O3.js → chunk-HLFS6WV2.js} +2 -2
  39. package/chunks/chunk-HR2TU42B.js +1228 -0
  40. package/chunks/{chunk-BFRB6HB2.js → chunk-HUNAPTKV.js} +3 -3
  41. package/chunks/chunk-IO7R7WBM.js +114 -0
  42. package/chunks/{chunk-WEBMRWEG.js → chunk-IXT64DV5.js} +656 -1868
  43. package/chunks/{chunk-3MOLBTLS.js → chunk-K2PWUPUI.js} +2 -2
  44. package/chunks/{chunk-WXQ6BJ6A.js → chunk-LCRTAQN2.js} +7 -7
  45. package/chunks/{chunk-SVJEDVYK.js → chunk-LPTRPRZR.js} +5 -5
  46. package/chunks/{chunk-CMKXP5RR.js → chunk-LYUAM3TG.js} +3 -3
  47. package/chunks/{chunk-BVAZO4WA.js → chunk-MICHDTBK.js} +3 -3
  48. package/chunks/{chunk-UCYRA73C.js → chunk-OAYUPGF6.js} +4 -4
  49. package/chunks/{chunk-XM5NLHYU.js → chunk-OWLJYJ5O.js} +14 -14
  50. package/chunks/{chunk-BKZFDZ23.js → chunk-QCUFBVIZ.js} +3 -3
  51. package/chunks/chunk-RE5EZDG2.js +5523 -0
  52. package/chunks/{chunk-ASUR522M.js → chunk-RRD4XXPU.js} +9 -9
  53. package/chunks/{chunk-AHTBZC3E.js → chunk-RSIUX3RW.js} +4 -4
  54. package/chunks/{chunk-BZNEY2ZS.js → chunk-SJBCK2EI.js} +15268 -16053
  55. package/chunks/{chunk-IOL7D5YV.js → chunk-SQCBHFWN.js} +3 -3
  56. package/chunks/chunk-TH2LW437.js +7829 -0
  57. package/chunks/{chunk-WVTBZEQO.js → chunk-TM74SSHC.js} +8 -8
  58. package/chunks/{chunk-U5FLXGHT.js → chunk-TO35Y326.js} +13 -729
  59. package/chunks/chunk-TRH2PJSN.js +547 -0
  60. package/chunks/{chunk-YYRBQVFE.js → chunk-TZFIAMWZ.js} +70 -16
  61. package/chunks/chunk-UELXHK2Y.js +1950 -0
  62. package/chunks/{chunk-RJWOYEOG.js → chunk-UEX7PFSE.js} +5 -5
  63. package/chunks/{chunk-VQG4FT5D.js → chunk-UFHN6RIU.js} +2 -2
  64. package/chunks/{chunk-JQHOLLTD.js → chunk-UU7PQP6N.js} +9 -9
  65. package/chunks/{chunk-BFR2CDV5.js → chunk-UV5QWZGE.js} +283 -153
  66. package/chunks/{chunk-WU6AFRAZ.js → chunk-V36HVTUL.js} +12 -12
  67. package/chunks/{chunk-IR537GON.js → chunk-VCSFCHAJ.js} +2 -2
  68. package/chunks/{chunk-YLMN3N25.js → chunk-VIT5ALXF.js} +3 -3
  69. package/chunks/{chunk-BATRQBOR.js → chunk-VMRRNRMR.js} +41 -41
  70. package/chunks/{chunk-72CISA2D.js → chunk-VNRY6AWF.js} +89 -41
  71. package/chunks/chunk-W6UWZFKL.js +298 -0
  72. package/chunks/{chunk-3KPWWJCI.js → chunk-XFCTUKXR.js} +88 -88
  73. package/chunks/{chunk-GMT2AZKM.js → chunk-YIQSGNAA.js} +897 -130
  74. package/chunks/codex-models-7TLJSY3L.js +17 -0
  75. package/chunks/{commands-TBC2F5CE.js → commands-NEI7L3QA.js} +2836 -1424
  76. package/chunks/corpus-v1.json +2 -2
  77. package/chunks/data/appsec-archetypes.json +2 -2
  78. package/chunks/data/chromium-archetypes.json +1 -1
  79. package/chunks/data/freebsd-archetypes.json +1 -1
  80. package/chunks/data/kernel-archetypes.json +2 -2
  81. package/chunks/db-5AP3JB4W.js +16 -0
  82. package/chunks/{disclose-EKTWSCGW.js → disclose-LDNKAVRH.js} +13 -11
  83. package/chunks/{dist-4YICS2J2.js → dist-3FNZIBB4.js} +394 -404
  84. package/chunks/{dist-4MAW5X6L.js → dist-5YHYNLI3.js} +6 -6
  85. package/chunks/{dist-FMGSR3DW.js → dist-DD4H6HMQ.js} +13 -5
  86. package/chunks/dist-KEULE5IQ.js +21914 -0
  87. package/chunks/dist-XZB53PS5.js +53 -0
  88. package/chunks/eval-runner-43BO2C4T.js +26 -0
  89. package/chunks/example-manifest.json +2 -2
  90. package/chunks/{exploit-agent-45YQOHPJ.js → exploit-agent-N4A5ELBK.js} +4 -4
  91. package/chunks/{exploit-autoclimb-UZGEMGYT.js → exploit-autoclimb-N7P6KIF5.js} +6 -6
  92. package/chunks/{exploit-climb-SG23KB2G.js → exploit-climb-WNEJUB5W.js} +12 -12
  93. package/chunks/fix-Z452M4EC.js +26 -0
  94. package/chunks/{github-issues-MJ6OYOOU.js → github-issues-IGTTWM7V.js} +7 -7
  95. package/chunks/harness-QJJJVSG4.js +22 -0
  96. package/chunks/http-conformance-U5F6GKYG.js +11 -0
  97. package/chunks/http-sender-I5XFFY35.js +10 -0
  98. package/chunks/hunt-scan-K6D2V3PX.js +36 -0
  99. package/chunks/{identity-6ZAIIWOR.js → identity-62SVRW4H.js} +5 -5
  100. package/chunks/{kernel-primitive-7U6CWHXD.js → kernel-primitive-TKUACPKD.js} +6 -6
  101. package/chunks/{kernel-vm-runner-3JAU4O6J.js → kernel-vm-runner-RAAO2PGT.js} +6 -6
  102. package/chunks/memsafety-scan-FCPAXIZE.js +16 -0
  103. package/chunks/{native-loop-RJCJPOUS.js → native-loop-2ZRJENZ3.js} +17 -18
  104. package/chunks/{npm-detectors-KB5Y5ZFX.js → npm-detectors-Z2ZIQCN4.js} +6 -6
  105. package/chunks/npm-dynamic-discovery-5J7FT3XM.js +13 -0
  106. package/chunks/orchestrate-2GWGNTBF.js +58 -0
  107. package/chunks/{pre-recon-cve-66EB6G4M.js → pre-recon-cve-X2K2P5YQ.js} +4 -4
  108. package/chunks/prepare-KYHGFWCJ.js +13 -0
  109. package/chunks/process-N245QIQG.js +12 -0
  110. package/chunks/{run-D56MPDKY.js → run-U3XU4CTC.js} +11507 -13632
  111. package/chunks/{runtime-G7YWIO3B.js → runtime-G75TEWQY.js} +10 -11
  112. package/chunks/runtime-XFWJTBUO.js +12 -0
  113. package/chunks/{scan-stream-FHI2FYZE.js → scan-stream-BMOCPKQX.js} +7 -7
  114. package/chunks/scope-WXI46UHJ.js +21 -0
  115. package/chunks/{session-store-GZ4A4KYT.js → session-store-27L3ZU73.js} +6 -6
  116. package/chunks/source-files-REHOM44I.js +12 -0
  117. package/chunks/{specdrift-WCLH6TTQ.js → specdrift-AFS54WEJ.js} +5 -5
  118. package/chunks/token-KRWP5JYA.js +72 -0
  119. package/chunks/token-util-DWTL33S3.js +8 -0
  120. package/chunks/variant-candidates-YWZORZMK.js +13 -0
  121. package/chunks/{web-recon-prepass-JJGPEOLE.js → web-recon-prepass-YVMFXCIK.js} +9 -9
  122. package/cli-path-traversal-fixture.js +352 -0
  123. package/dashboard/assets/bot-Bg1Tp9_d.js +1 -0
  124. package/dashboard/assets/dist-B_dDCPbu.js +1 -0
  125. package/dashboard/assets/findings-page-mayGhNx6.js +5 -0
  126. package/dashboard/assets/format--susmHX7.js +1 -0
  127. package/dashboard/assets/input-TuVPR3Zl.js +1 -0
  128. package/dashboard/assets/jsx-runtime-MGseXjj5.js +3 -0
  129. package/dashboard/assets/live-page-HWWHX99U.js +1 -0
  130. package/dashboard/assets/meta-tile-ckHo-w7k.js +1 -0
  131. package/dashboard/assets/operations-BxZ0OoXO.js +10 -0
  132. package/dashboard/assets/operations-CMFVrXEe.css +2 -0
  133. package/dashboard/assets/operations-app-D3d35rgo.js +46 -0
  134. package/dashboard/assets/overview-page-W_4IteEr.js +1 -0
  135. package/dashboard/assets/page-header-Bw9AJgBV.js +1 -0
  136. package/dashboard/assets/scans-page-CgzVXHnn.js +1 -0
  137. package/dashboard/assets/siren-KQj8QAnJ.js +1 -0
  138. package/dashboard/assets/table-8EDklulN.js +1 -0
  139. package/dashboard/assets/tabs-CFHPOwg8.js +1 -0
  140. package/dashboard/index.html +4 -5
  141. package/node_modules/node-addon-api/LICENSE.md +9 -0
  142. package/node_modules/node-addon-api/README.md +95 -0
  143. package/node_modules/node-addon-api/common.gypi +21 -0
  144. package/node_modules/node-addon-api/except.gypi +25 -0
  145. package/node_modules/node-addon-api/index.js +14 -0
  146. package/node_modules/node-addon-api/napi-inl.deprecated.h +186 -0
  147. package/node_modules/node-addon-api/napi-inl.h +7250 -0
  148. package/node_modules/node-addon-api/napi.h +3463 -0
  149. package/node_modules/node-addon-api/node_addon_api.gyp +42 -0
  150. package/node_modules/node-addon-api/node_api.gyp +9 -0
  151. package/node_modules/node-addon-api/noexcept.gypi +26 -0
  152. package/node_modules/node-addon-api/nothing.c +0 -0
  153. package/node_modules/node-addon-api/package-support.json +21 -0
  154. package/node_modules/node-addon-api/package.json +481 -0
  155. package/node_modules/node-addon-api/tools/README.md +73 -0
  156. package/node_modules/node-addon-api/tools/check-napi.js +99 -0
  157. package/node_modules/node-addon-api/tools/clang-format.js +71 -0
  158. package/node_modules/node-addon-api/tools/conversion.js +301 -0
  159. package/node_modules/node-gyp-build/LICENSE +21 -0
  160. package/node_modules/node-gyp-build/README.md +58 -0
  161. package/node_modules/node-gyp-build/SECURITY.md +5 -0
  162. package/node_modules/node-gyp-build/bin.js +84 -0
  163. package/node_modules/node-gyp-build/build-test.js +19 -0
  164. package/node_modules/node-gyp-build/index.js +6 -0
  165. package/node_modules/node-gyp-build/node-gyp-build.js +207 -0
  166. package/node_modules/node-gyp-build/optional.js +7 -0
  167. package/node_modules/node-gyp-build/package.json +43 -0
  168. package/node_modules/tree-sitter/LICENSE +21 -0
  169. package/node_modules/tree-sitter/README.md +90 -0
  170. package/node_modules/tree-sitter/binding.gyp +76 -0
  171. package/node_modules/tree-sitter/index.js +895 -0
  172. package/node_modules/tree-sitter/package.json +62 -0
  173. package/node_modules/tree-sitter/prebuilds/darwin-arm64/tree-sitter.node +0 -0
  174. package/node_modules/tree-sitter/prebuilds/darwin-x64/tree-sitter.node +0 -0
  175. package/node_modules/tree-sitter/prebuilds/linux-x64/tree-sitter.node +0 -0
  176. package/node_modules/tree-sitter/prebuilds/win32-x64/tree-sitter.node +0 -0
  177. package/node_modules/tree-sitter/src/addon_data.h +47 -0
  178. package/node_modules/tree-sitter/src/binding.cc +35 -0
  179. package/node_modules/tree-sitter/src/conversions.cc +140 -0
  180. package/node_modules/tree-sitter/src/conversions.h +22 -0
  181. package/node_modules/tree-sitter/src/language.cc +106 -0
  182. package/node_modules/tree-sitter/src/language.h +17 -0
  183. package/node_modules/tree-sitter/src/logger.cc +70 -0
  184. package/node_modules/tree-sitter/src/logger.h +19 -0
  185. package/node_modules/tree-sitter/src/lookaheaditerator.cc +122 -0
  186. package/node_modules/tree-sitter/src/lookaheaditerator.h +33 -0
  187. package/node_modules/tree-sitter/src/node.cc +1056 -0
  188. package/node_modules/tree-sitter/src/node.h +30 -0
  189. package/node_modules/tree-sitter/src/parser.cc +298 -0
  190. package/node_modules/tree-sitter/src/parser.h +35 -0
  191. package/node_modules/tree-sitter/src/query.cc +383 -0
  192. package/node_modules/tree-sitter/src/query.h +39 -0
  193. package/node_modules/tree-sitter/src/tree.cc +307 -0
  194. package/node_modules/tree-sitter/src/tree.h +45 -0
  195. package/node_modules/tree-sitter/src/tree_cursor.cc +213 -0
  196. package/node_modules/tree-sitter/src/tree_cursor.h +52 -0
  197. package/node_modules/tree-sitter/tree-sitter.d.ts +211 -0
  198. package/node_modules/tree-sitter/vendor/tree-sitter/LICENSE +21 -0
  199. package/node_modules/tree-sitter/vendor/tree-sitter/README.md +21 -0
  200. package/node_modules/tree-sitter/vendor/tree-sitter/lib/README.md +6 -0
  201. package/node_modules/tree-sitter/vendor/tree-sitter/lib/include/tree_sitter/api.h +1266 -0
  202. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.c +48 -0
  203. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/alloc.h +41 -0
  204. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/array.h +290 -0
  205. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/atomic.h +68 -0
  206. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/clock.h +146 -0
  207. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/error_costs.h +11 -0
  208. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.c +501 -0
  209. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/get_changed_ranges.h +36 -0
  210. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/host.h +21 -0
  211. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.c +221 -0
  212. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/language.h +299 -0
  213. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/length.h +52 -0
  214. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.c +419 -0
  215. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lexer.h +49 -0
  216. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/lib.c +14 -0
  217. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/node.c +774 -0
  218. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.c +2151 -0
  219. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/parser.h +230 -0
  220. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/point.h +62 -0
  221. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/query.c +4134 -0
  222. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reduce_action.h +34 -0
  223. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/reusable_node.h +95 -0
  224. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.c +899 -0
  225. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/stack.h +133 -0
  226. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.c +1060 -0
  227. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/subtree.h +382 -0
  228. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.c +165 -0
  229. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree.h +31 -0
  230. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.c +714 -0
  231. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/tree_cursor.h +48 -0
  232. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ICU_SHA +1 -0
  233. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/LICENSE +414 -0
  234. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/README.md +29 -0
  235. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/ptypes.h +1 -0
  236. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/umachine.h +448 -0
  237. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/urename.h +1 -0
  238. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf.h +1 -0
  239. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf16.h +733 -0
  240. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode/utf8.h +881 -0
  241. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/unicode.h +50 -0
  242. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib-symbols.txt +23 -0
  243. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/stdlib.c +109 -0
  244. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm/wasm-stdlib.h +1294 -0
  245. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.c +1823 -0
  246. package/node_modules/tree-sitter/vendor/tree-sitter/lib/src/wasm_store.h +31 -0
  247. package/node_modules/tree-sitter/vendor/tree-sitter/test/fixtures/grammars/.gitkeep +0 -0
  248. package/node_modules/tree-sitter-c/LICENSE +21 -0
  249. package/node_modules/tree-sitter-c/README.md +18 -0
  250. package/node_modules/tree-sitter-c/binding.gyp +20 -0
  251. package/node_modules/tree-sitter-c/bindings/node/binding.cc +20 -0
  252. package/node_modules/tree-sitter-c/bindings/node/index.d.ts +28 -0
  253. package/node_modules/tree-sitter-c/bindings/node/index.js +7 -0
  254. package/node_modules/tree-sitter-c/grammar.js +1463 -0
  255. package/node_modules/tree-sitter-c/package.json +108 -0
  256. package/node_modules/tree-sitter-c/prebuilds/darwin-arm64/tree-sitter-c.node +0 -0
  257. package/node_modules/tree-sitter-c/prebuilds/darwin-x64/tree-sitter-c.node +0 -0
  258. package/node_modules/tree-sitter-c/prebuilds/linux-x64/tree-sitter-c.node +0 -0
  259. package/node_modules/tree-sitter-c/prebuilds/win32-x64/tree-sitter-c.node +0 -0
  260. package/node_modules/tree-sitter-c/queries/highlights.scm +81 -0
  261. package/node_modules/tree-sitter-c/queries/tags.scm +9 -0
  262. package/node_modules/tree-sitter-c/src/grammar.json +9682 -0
  263. package/node_modules/tree-sitter-c/src/node-types.json +4556 -0
  264. package/node_modules/tree-sitter-c/src/parser.c +113852 -0
  265. package/node_modules/tree-sitter-c/src/tree_sitter/alloc.h +54 -0
  266. package/node_modules/tree-sitter-c/src/tree_sitter/array.h +290 -0
  267. package/node_modules/tree-sitter-c/src/tree_sitter/parser.h +265 -0
  268. package/package.json +20 -13
  269. package/vendor/tree-sitter-0.21.1-node24.json +16 -0
  270. package/vendor/tree-sitter-0.21.1-node24.tgz +0 -0
  271. package/chunks/adapt-loop-SMH6V4PD.js +0 -18
  272. package/chunks/appsec-catalog-CBWHGTEL.js +0 -24
  273. package/chunks/chunk-242TMK6G.js +0 -110
  274. package/chunks/chunk-57ZENEX2.js +0 -169
  275. package/chunks/chunk-ADOLI6DT.js +0 -102
  276. package/chunks/chunk-ATATQACO.js +0 -471
  277. package/chunks/chunk-C2WXWFBB.js +0 -1070
  278. package/chunks/chunk-F3WBKITT.js +0 -687
  279. package/chunks/chunk-H2FFLZNK.js +0 -3
  280. package/chunks/chunk-LP3HHYQU.js +0 -245
  281. package/chunks/chunk-QI233I24.js +0 -333
  282. package/chunks/chunk-RRMJC3ZE.js +0 -105
  283. package/chunks/chunk-Z5FA2XOX.js +0 -2798
  284. package/chunks/cost-ledger-NU63MYZM.js +0 -13
  285. package/chunks/db-KFWOAUUB.js +0 -16
  286. package/chunks/eval-runner-7ZF472KV.js +0 -27
  287. package/chunks/fix-IG7LYXH3.js +0 -12
  288. package/chunks/harness-7ODOLOWU.js +0 -22
  289. package/chunks/http-conformance-DU66MZIU.js +0 -11
  290. package/chunks/http-sender-GWH2IYEA.js +0 -10
  291. package/chunks/hunt-scan-MMKUOETU.js +0 -38
  292. package/chunks/memsafety-scan-J7SECV5W.js +0 -16
  293. package/chunks/npm-dynamic-discovery-AHROOZDB.js +0 -13
  294. package/chunks/orchestrate-OC2VZN2X.js +0 -62
  295. package/chunks/pipeline-BZK5BLJR.js +0 -14
  296. package/chunks/prepare-MYY743TK.js +0 -13
  297. package/chunks/process-LQRCS5OY.js +0 -13
  298. package/chunks/replay-runner-45G3VU7X.js +0 -39
  299. package/chunks/runtime-J7PLXZNM.js +0 -12
  300. package/chunks/scope-BI7BF4ZY.js +0 -18
  301. package/chunks/source-files-PWRQR6LY.js +0 -12
  302. package/chunks/variant-candidates-YERCYMPD.js +0 -13
  303. package/dashboard/assets/0sec-icon-66SreztZ.gif +0 -0
  304. package/dashboard/assets/bot-yILPnRgD.js +0 -1
  305. package/dashboard/assets/chevron-down-BeDJ-Vka.js +0 -1
  306. package/dashboard/assets/circle-alert-BEnMBMT-.js +0 -1
  307. package/dashboard/assets/client-DRYsuOGl.js +0 -9
  308. package/dashboard/assets/copy-Bi5vzoF9.js +0 -1
  309. package/dashboard/assets/desktop-CXTQonNm.js +0 -32
  310. package/dashboard/assets/desktop-NOekk4QS.css +0 -1
  311. package/dashboard/assets/dist-CmX-h7a4.js +0 -1
  312. package/dashboard/assets/dist-DAwYQmf_.js +0 -45
  313. package/dashboard/assets/findings-page-CACW9nw2.js +0 -5
  314. package/dashboard/assets/format-PoISqsES.js +0 -1
  315. package/dashboard/assets/jsx-runtime-C7oxC63R.js +0 -1
  316. package/dashboard/assets/live-page-DrgQqQK5.js +0 -1
  317. package/dashboard/assets/meta-tile-CcskIV_o.js +0 -1
  318. package/dashboard/assets/operations-BKE8T-vY.css +0 -2
  319. package/dashboard/assets/operations-D8nUP5_m.js +0 -4
  320. package/dashboard/assets/operations-app-CQQhG54n.js +0 -2
  321. package/dashboard/assets/overview-page-DTGS8dPo.js +0 -1
  322. package/dashboard/assets/page-header-MFVvEtZW.js +0 -1
  323. package/dashboard/assets/play-Dwo-9xt6.js +0 -1
  324. package/dashboard/assets/scans-page-ChVtq8Us.js +0 -1
  325. package/dashboard/assets/search-CiooTLck.js +0 -1
  326. package/dashboard/assets/siren-CCBwTSuk.js +0 -1
  327. package/dashboard/assets/table-BYS-nIVA.js +0 -1
  328. package/dashboard/assets/tabs-DivxbhQy.js +0 -1
  329. package/dashboard/desktop.html +0 -21
@@ -0,0 +1,714 @@
1
+ #include "tree_sitter/api.h"
2
+ #include "./alloc.h"
3
+ #include "./tree_cursor.h"
4
+ #include "./language.h"
5
+ #include "./tree.h"
6
+
7
+ typedef struct {
8
+ Subtree parent;
9
+ const TSTree *tree;
10
+ Length position;
11
+ uint32_t child_index;
12
+ uint32_t structural_child_index;
13
+ uint32_t descendant_index;
14
+ const TSSymbol *alias_sequence;
15
+ } CursorChildIterator;
16
+
17
+ // CursorChildIterator
18
+
19
+ static inline bool ts_tree_cursor_is_entry_visible(const TreeCursor *self, uint32_t index) {
20
+ TreeCursorEntry *entry = &self->stack.contents[index];
21
+ if (index == 0 || ts_subtree_visible(*entry->subtree)) {
22
+ return true;
23
+ } else if (!ts_subtree_extra(*entry->subtree)) {
24
+ TreeCursorEntry *parent_entry = &self->stack.contents[index - 1];
25
+ return ts_language_alias_at(
26
+ self->tree->language,
27
+ parent_entry->subtree->ptr->production_id,
28
+ entry->structural_child_index
29
+ );
30
+ } else {
31
+ return false;
32
+ }
33
+ }
34
+
35
+ static inline CursorChildIterator ts_tree_cursor_iterate_children(const TreeCursor *self) {
36
+ TreeCursorEntry *last_entry = array_back(&self->stack);
37
+ if (ts_subtree_child_count(*last_entry->subtree) == 0) {
38
+ return (CursorChildIterator) {NULL_SUBTREE, self->tree, length_zero(), 0, 0, 0, NULL};
39
+ }
40
+ const TSSymbol *alias_sequence = ts_language_alias_sequence(
41
+ self->tree->language,
42
+ last_entry->subtree->ptr->production_id
43
+ );
44
+
45
+ uint32_t descendant_index = last_entry->descendant_index;
46
+ if (ts_tree_cursor_is_entry_visible(self, self->stack.size - 1)) {
47
+ descendant_index += 1;
48
+ }
49
+
50
+ return (CursorChildIterator) {
51
+ .tree = self->tree,
52
+ .parent = *last_entry->subtree,
53
+ .position = last_entry->position,
54
+ .child_index = 0,
55
+ .structural_child_index = 0,
56
+ .descendant_index = descendant_index,
57
+ .alias_sequence = alias_sequence,
58
+ };
59
+ }
60
+
61
+ static inline bool ts_tree_cursor_child_iterator_next(
62
+ CursorChildIterator *self,
63
+ TreeCursorEntry *result,
64
+ bool *visible
65
+ ) {
66
+ if (!self->parent.ptr || self->child_index == self->parent.ptr->child_count) return false;
67
+ const Subtree *child = &ts_subtree_children(self->parent)[self->child_index];
68
+ *result = (TreeCursorEntry) {
69
+ .subtree = child,
70
+ .position = self->position,
71
+ .child_index = self->child_index,
72
+ .structural_child_index = self->structural_child_index,
73
+ .descendant_index = self->descendant_index,
74
+ };
75
+ *visible = ts_subtree_visible(*child);
76
+ bool extra = ts_subtree_extra(*child);
77
+ if (!extra) {
78
+ if (self->alias_sequence) {
79
+ *visible |= self->alias_sequence[self->structural_child_index];
80
+ }
81
+ self->structural_child_index++;
82
+ }
83
+
84
+ self->descendant_index += ts_subtree_visible_descendant_count(*child);
85
+ if (*visible) {
86
+ self->descendant_index += 1;
87
+ }
88
+
89
+ self->position = length_add(self->position, ts_subtree_size(*child));
90
+ self->child_index++;
91
+
92
+ if (self->child_index < self->parent.ptr->child_count) {
93
+ Subtree next_child = ts_subtree_children(self->parent)[self->child_index];
94
+ self->position = length_add(self->position, ts_subtree_padding(next_child));
95
+ }
96
+
97
+ return true;
98
+ }
99
+
100
+ // Return a position that, when `b` is added to it, yields `a`. This
101
+ // can only be computed if `b` has zero rows. Otherwise, this function
102
+ // returns `LENGTH_UNDEFINED`, and the caller needs to recompute
103
+ // the position some other way.
104
+ static inline Length length_backtrack(Length a, Length b) {
105
+ if (length_is_undefined(a) || b.extent.row != 0) {
106
+ return LENGTH_UNDEFINED;
107
+ }
108
+
109
+ Length result;
110
+ result.bytes = a.bytes - b.bytes;
111
+ result.extent.row = a.extent.row;
112
+ result.extent.column = a.extent.column - b.extent.column;
113
+ return result;
114
+ }
115
+
116
+ static inline bool ts_tree_cursor_child_iterator_previous(
117
+ CursorChildIterator *self,
118
+ TreeCursorEntry *result,
119
+ bool *visible
120
+ ) {
121
+ // this is mostly a reverse `ts_tree_cursor_child_iterator_next` taking into
122
+ // account unsigned underflow
123
+ if (!self->parent.ptr || (int8_t)self->child_index == -1) return false;
124
+ const Subtree *child = &ts_subtree_children(self->parent)[self->child_index];
125
+ *result = (TreeCursorEntry) {
126
+ .subtree = child,
127
+ .position = self->position,
128
+ .child_index = self->child_index,
129
+ .structural_child_index = self->structural_child_index,
130
+ };
131
+ *visible = ts_subtree_visible(*child);
132
+ bool extra = ts_subtree_extra(*child);
133
+ if (!extra && self->alias_sequence) {
134
+ *visible |= self->alias_sequence[self->structural_child_index];
135
+ self->structural_child_index--;
136
+ }
137
+
138
+ self->position = length_backtrack(self->position, ts_subtree_padding(*child));
139
+ self->child_index--;
140
+
141
+ // unsigned can underflow so compare it to child_count
142
+ if (self->child_index < self->parent.ptr->child_count) {
143
+ Subtree previous_child = ts_subtree_children(self->parent)[self->child_index];
144
+ Length size = ts_subtree_size(previous_child);
145
+ self->position = length_backtrack(self->position, size);
146
+ }
147
+
148
+ return true;
149
+ }
150
+
151
+ // TSTreeCursor - lifecycle
152
+
153
+ TSTreeCursor ts_tree_cursor_new(TSNode node) {
154
+ TSTreeCursor self = {NULL, NULL, {0, 0, 0}};
155
+ ts_tree_cursor_init((TreeCursor *)&self, node);
156
+ return self;
157
+ }
158
+
159
+ void ts_tree_cursor_reset(TSTreeCursor *_self, TSNode node) {
160
+ ts_tree_cursor_init((TreeCursor *)_self, node);
161
+ }
162
+
163
+ void ts_tree_cursor_init(TreeCursor *self, TSNode node) {
164
+ self->tree = node.tree;
165
+ self->root_alias_symbol = node.context[3];
166
+ array_clear(&self->stack);
167
+ array_push(&self->stack, ((TreeCursorEntry) {
168
+ .subtree = (const Subtree *)node.id,
169
+ .position = {
170
+ ts_node_start_byte(node),
171
+ ts_node_start_point(node)
172
+ },
173
+ .child_index = 0,
174
+ .structural_child_index = 0,
175
+ .descendant_index = 0,
176
+ }));
177
+ }
178
+
179
+ void ts_tree_cursor_delete(TSTreeCursor *_self) {
180
+ TreeCursor *self = (TreeCursor *)_self;
181
+ array_delete(&self->stack);
182
+ }
183
+
184
+ // TSTreeCursor - walking the tree
185
+
186
+ TreeCursorStep ts_tree_cursor_goto_first_child_internal(TSTreeCursor *_self) {
187
+ TreeCursor *self = (TreeCursor *)_self;
188
+ bool visible;
189
+ TreeCursorEntry entry;
190
+ CursorChildIterator iterator = ts_tree_cursor_iterate_children(self);
191
+ while (ts_tree_cursor_child_iterator_next(&iterator, &entry, &visible)) {
192
+ if (visible) {
193
+ array_push(&self->stack, entry);
194
+ return TreeCursorStepVisible;
195
+ }
196
+ if (ts_subtree_visible_child_count(*entry.subtree) > 0) {
197
+ array_push(&self->stack, entry);
198
+ return TreeCursorStepHidden;
199
+ }
200
+ }
201
+ return TreeCursorStepNone;
202
+ }
203
+
204
+ bool ts_tree_cursor_goto_first_child(TSTreeCursor *self) {
205
+ for (;;) {
206
+ switch (ts_tree_cursor_goto_first_child_internal(self)) {
207
+ case TreeCursorStepHidden:
208
+ continue;
209
+ case TreeCursorStepVisible:
210
+ return true;
211
+ default:
212
+ return false;
213
+ }
214
+ }
215
+ return false;
216
+ }
217
+
218
+ TreeCursorStep ts_tree_cursor_goto_last_child_internal(TSTreeCursor *_self) {
219
+ TreeCursor *self = (TreeCursor *)_self;
220
+ bool visible;
221
+ TreeCursorEntry entry;
222
+ CursorChildIterator iterator = ts_tree_cursor_iterate_children(self);
223
+ if (!iterator.parent.ptr || iterator.parent.ptr->child_count == 0) return TreeCursorStepNone;
224
+
225
+ TreeCursorEntry last_entry = {0};
226
+ TreeCursorStep last_step = TreeCursorStepNone;
227
+ while (ts_tree_cursor_child_iterator_next(&iterator, &entry, &visible)) {
228
+ if (visible) {
229
+ last_entry = entry;
230
+ last_step = TreeCursorStepVisible;
231
+ }
232
+ else if (ts_subtree_visible_child_count(*entry.subtree) > 0) {
233
+ last_entry = entry;
234
+ last_step = TreeCursorStepHidden;
235
+ }
236
+ }
237
+ if (last_entry.subtree) {
238
+ array_push(&self->stack, last_entry);
239
+ return last_step;
240
+ }
241
+
242
+ return TreeCursorStepNone;
243
+ }
244
+
245
+ bool ts_tree_cursor_goto_last_child(TSTreeCursor *self) {
246
+ for (;;) {
247
+ switch (ts_tree_cursor_goto_last_child_internal(self)) {
248
+ case TreeCursorStepHidden:
249
+ continue;
250
+ case TreeCursorStepVisible:
251
+ return true;
252
+ default:
253
+ return false;
254
+ }
255
+ }
256
+ return false;
257
+ }
258
+
259
+ static inline int64_t ts_tree_cursor_goto_first_child_for_byte_and_point(
260
+ TSTreeCursor *_self,
261
+ uint32_t goal_byte,
262
+ TSPoint goal_point
263
+ ) {
264
+ TreeCursor *self = (TreeCursor *)_self;
265
+ uint32_t initial_size = self->stack.size;
266
+ uint32_t visible_child_index = 0;
267
+
268
+ bool did_descend;
269
+ do {
270
+ did_descend = false;
271
+
272
+ bool visible;
273
+ TreeCursorEntry entry;
274
+ CursorChildIterator iterator = ts_tree_cursor_iterate_children(self);
275
+ while (ts_tree_cursor_child_iterator_next(&iterator, &entry, &visible)) {
276
+ Length entry_end = length_add(entry.position, ts_subtree_size(*entry.subtree));
277
+ bool at_goal = entry_end.bytes >= goal_byte && point_gte(entry_end.extent, goal_point);
278
+ uint32_t visible_child_count = ts_subtree_visible_child_count(*entry.subtree);
279
+ if (at_goal) {
280
+ if (visible) {
281
+ array_push(&self->stack, entry);
282
+ return visible_child_index;
283
+ }
284
+ if (visible_child_count > 0) {
285
+ array_push(&self->stack, entry);
286
+ did_descend = true;
287
+ break;
288
+ }
289
+ } else if (visible) {
290
+ visible_child_index++;
291
+ } else {
292
+ visible_child_index += visible_child_count;
293
+ }
294
+ }
295
+ } while (did_descend);
296
+
297
+ self->stack.size = initial_size;
298
+ return -1;
299
+ }
300
+
301
+ int64_t ts_tree_cursor_goto_first_child_for_byte(TSTreeCursor *self, uint32_t goal_byte) {
302
+ return ts_tree_cursor_goto_first_child_for_byte_and_point(self, goal_byte, POINT_ZERO);
303
+ }
304
+
305
+ int64_t ts_tree_cursor_goto_first_child_for_point(TSTreeCursor *self, TSPoint goal_point) {
306
+ return ts_tree_cursor_goto_first_child_for_byte_and_point(self, 0, goal_point);
307
+ }
308
+
309
+ TreeCursorStep ts_tree_cursor_goto_sibling_internal(
310
+ TSTreeCursor *_self,
311
+ bool (*advance)(CursorChildIterator *, TreeCursorEntry *, bool *)) {
312
+ TreeCursor *self = (TreeCursor *)_self;
313
+ uint32_t initial_size = self->stack.size;
314
+
315
+ while (self->stack.size > 1) {
316
+ TreeCursorEntry entry = array_pop(&self->stack);
317
+ CursorChildIterator iterator = ts_tree_cursor_iterate_children(self);
318
+ iterator.child_index = entry.child_index;
319
+ iterator.structural_child_index = entry.structural_child_index;
320
+ iterator.position = entry.position;
321
+ iterator.descendant_index = entry.descendant_index;
322
+
323
+ bool visible = false;
324
+ advance(&iterator, &entry, &visible);
325
+ if (visible && self->stack.size + 1 < initial_size) break;
326
+
327
+ while (advance(&iterator, &entry, &visible)) {
328
+ if (visible) {
329
+ array_push(&self->stack, entry);
330
+ return TreeCursorStepVisible;
331
+ }
332
+
333
+ if (ts_subtree_visible_child_count(*entry.subtree)) {
334
+ array_push(&self->stack, entry);
335
+ return TreeCursorStepHidden;
336
+ }
337
+ }
338
+ }
339
+
340
+ self->stack.size = initial_size;
341
+ return TreeCursorStepNone;
342
+ }
343
+
344
+ TreeCursorStep ts_tree_cursor_goto_next_sibling_internal(TSTreeCursor *_self) {
345
+ return ts_tree_cursor_goto_sibling_internal(_self, ts_tree_cursor_child_iterator_next);
346
+ }
347
+
348
+ bool ts_tree_cursor_goto_next_sibling(TSTreeCursor *self) {
349
+ switch (ts_tree_cursor_goto_next_sibling_internal(self)) {
350
+ case TreeCursorStepHidden:
351
+ ts_tree_cursor_goto_first_child(self);
352
+ return true;
353
+ case TreeCursorStepVisible:
354
+ return true;
355
+ default:
356
+ return false;
357
+ }
358
+ }
359
+
360
+ TreeCursorStep ts_tree_cursor_goto_previous_sibling_internal(TSTreeCursor *_self) {
361
+ // since subtracting across row loses column information, we may have to
362
+ // restore it
363
+ TreeCursor *self = (TreeCursor *)_self;
364
+
365
+ // for that, save current position before traversing
366
+ TreeCursorStep step = ts_tree_cursor_goto_sibling_internal(
367
+ _self, ts_tree_cursor_child_iterator_previous);
368
+ if (step == TreeCursorStepNone)
369
+ return step;
370
+
371
+ // if length is already valid, there's no need to recompute it
372
+ if (!length_is_undefined(array_back(&self->stack)->position))
373
+ return step;
374
+
375
+ // restore position from the parent node
376
+ const TreeCursorEntry *parent = &self->stack.contents[self->stack.size - 2];
377
+ Length position = parent->position;
378
+ uint32_t child_index = array_back(&self->stack)->child_index;
379
+ const Subtree *children = ts_subtree_children((*(parent->subtree)));
380
+
381
+ if (child_index > 0) {
382
+ // skip first child padding since its position should match the position of the parent
383
+ position = length_add(position, ts_subtree_size(children[0]));
384
+ for (uint32_t i = 1; i < child_index; ++i) {
385
+ position = length_add(position, ts_subtree_total_size(children[i]));
386
+ }
387
+ position = length_add(position, ts_subtree_padding(children[child_index]));
388
+ }
389
+
390
+ array_back(&self->stack)->position = position;
391
+
392
+ return step;
393
+ }
394
+
395
+ bool ts_tree_cursor_goto_previous_sibling(TSTreeCursor *self) {
396
+ switch (ts_tree_cursor_goto_previous_sibling_internal(self)) {
397
+ case TreeCursorStepHidden:
398
+ ts_tree_cursor_goto_last_child(self);
399
+ return true;
400
+ case TreeCursorStepVisible:
401
+ return true;
402
+ default:
403
+ return false;
404
+ }
405
+ }
406
+
407
+ bool ts_tree_cursor_goto_parent(TSTreeCursor *_self) {
408
+ TreeCursor *self = (TreeCursor *)_self;
409
+ for (unsigned i = self->stack.size - 2; i + 1 > 0; i--) {
410
+ if (ts_tree_cursor_is_entry_visible(self, i)) {
411
+ self->stack.size = i + 1;
412
+ return true;
413
+ }
414
+ }
415
+ return false;
416
+ }
417
+
418
+ void ts_tree_cursor_goto_descendant(
419
+ TSTreeCursor *_self,
420
+ uint32_t goal_descendant_index
421
+ ) {
422
+ TreeCursor *self = (TreeCursor *)_self;
423
+
424
+ // Ascend to the lowest ancestor that contains the goal node.
425
+ for (;;) {
426
+ uint32_t i = self->stack.size - 1;
427
+ TreeCursorEntry *entry = &self->stack.contents[i];
428
+ uint32_t next_descendant_index =
429
+ entry->descendant_index +
430
+ (ts_tree_cursor_is_entry_visible(self, i) ? 1 : 0) +
431
+ ts_subtree_visible_descendant_count(*entry->subtree);
432
+ if (
433
+ (entry->descendant_index <= goal_descendant_index) &&
434
+ (next_descendant_index > goal_descendant_index)
435
+ ) {
436
+ break;
437
+ } else if (self->stack.size <= 1) {
438
+ return;
439
+ } else {
440
+ self->stack.size--;
441
+ }
442
+ }
443
+
444
+ // Descend to the goal node.
445
+ bool did_descend = true;
446
+ do {
447
+ did_descend = false;
448
+ bool visible;
449
+ TreeCursorEntry entry;
450
+ CursorChildIterator iterator = ts_tree_cursor_iterate_children(self);
451
+ if (iterator.descendant_index > goal_descendant_index) {
452
+ return;
453
+ }
454
+
455
+ while (ts_tree_cursor_child_iterator_next(&iterator, &entry, &visible)) {
456
+ if (iterator.descendant_index > goal_descendant_index) {
457
+ array_push(&self->stack, entry);
458
+ if (visible && entry.descendant_index == goal_descendant_index) {
459
+ return;
460
+ } else {
461
+ did_descend = true;
462
+ break;
463
+ }
464
+ }
465
+ }
466
+ } while (did_descend);
467
+ }
468
+
469
+ uint32_t ts_tree_cursor_current_descendant_index(const TSTreeCursor *_self) {
470
+ const TreeCursor *self = (const TreeCursor *)_self;
471
+ TreeCursorEntry *last_entry = array_back(&self->stack);
472
+ return last_entry->descendant_index;
473
+ }
474
+
475
+ TSNode ts_tree_cursor_current_node(const TSTreeCursor *_self) {
476
+ const TreeCursor *self = (const TreeCursor *)_self;
477
+ TreeCursorEntry *last_entry = array_back(&self->stack);
478
+ TSSymbol alias_symbol = self->root_alias_symbol;
479
+ if (self->stack.size > 1 && !ts_subtree_extra(*last_entry->subtree)) {
480
+ TreeCursorEntry *parent_entry = &self->stack.contents[self->stack.size - 2];
481
+ alias_symbol = ts_language_alias_at(
482
+ self->tree->language,
483
+ parent_entry->subtree->ptr->production_id,
484
+ last_entry->structural_child_index
485
+ );
486
+ }
487
+ return ts_node_new(
488
+ self->tree,
489
+ last_entry->subtree,
490
+ last_entry->position,
491
+ alias_symbol
492
+ );
493
+ }
494
+
495
+ // Private - Get various facts about the current node that are needed
496
+ // when executing tree queries.
497
+ void ts_tree_cursor_current_status(
498
+ const TSTreeCursor *_self,
499
+ TSFieldId *field_id,
500
+ bool *has_later_siblings,
501
+ bool *has_later_named_siblings,
502
+ bool *can_have_later_siblings_with_this_field,
503
+ TSSymbol *supertypes,
504
+ unsigned *supertype_count
505
+ ) {
506
+ const TreeCursor *self = (const TreeCursor *)_self;
507
+ unsigned max_supertypes = *supertype_count;
508
+ *field_id = 0;
509
+ *supertype_count = 0;
510
+ *has_later_siblings = false;
511
+ *has_later_named_siblings = false;
512
+ *can_have_later_siblings_with_this_field = false;
513
+
514
+ // Walk up the tree, visiting the current node and its invisible ancestors,
515
+ // because fields can refer to nodes through invisible *wrapper* nodes,
516
+ for (unsigned i = self->stack.size - 1; i > 0; i--) {
517
+ TreeCursorEntry *entry = &self->stack.contents[i];
518
+ TreeCursorEntry *parent_entry = &self->stack.contents[i - 1];
519
+
520
+ const TSSymbol *alias_sequence = ts_language_alias_sequence(
521
+ self->tree->language,
522
+ parent_entry->subtree->ptr->production_id
523
+ );
524
+
525
+ #define subtree_symbol(subtree, structural_child_index) \
526
+ (( \
527
+ !ts_subtree_extra(subtree) && \
528
+ alias_sequence && \
529
+ alias_sequence[structural_child_index] \
530
+ ) ? \
531
+ alias_sequence[structural_child_index] : \
532
+ ts_subtree_symbol(subtree))
533
+
534
+ // Stop walking up when a visible ancestor is found.
535
+ TSSymbol entry_symbol = subtree_symbol(
536
+ *entry->subtree,
537
+ entry->structural_child_index
538
+ );
539
+ TSSymbolMetadata entry_metadata = ts_language_symbol_metadata(
540
+ self->tree->language,
541
+ entry_symbol
542
+ );
543
+ if (i != self->stack.size - 1 && entry_metadata.visible) break;
544
+
545
+ // Record any supertypes
546
+ if (entry_metadata.supertype && *supertype_count < max_supertypes) {
547
+ supertypes[*supertype_count] = entry_symbol;
548
+ (*supertype_count)++;
549
+ }
550
+
551
+ // Determine if the current node has later siblings.
552
+ if (!*has_later_siblings) {
553
+ unsigned sibling_count = parent_entry->subtree->ptr->child_count;
554
+ unsigned structural_child_index = entry->structural_child_index;
555
+ if (!ts_subtree_extra(*entry->subtree)) structural_child_index++;
556
+ for (unsigned j = entry->child_index + 1; j < sibling_count; j++) {
557
+ Subtree sibling = ts_subtree_children(*parent_entry->subtree)[j];
558
+ TSSymbolMetadata sibling_metadata = ts_language_symbol_metadata(
559
+ self->tree->language,
560
+ subtree_symbol(sibling, structural_child_index)
561
+ );
562
+ if (sibling_metadata.visible) {
563
+ *has_later_siblings = true;
564
+ if (*has_later_named_siblings) break;
565
+ if (sibling_metadata.named) {
566
+ *has_later_named_siblings = true;
567
+ break;
568
+ }
569
+ } else if (ts_subtree_visible_child_count(sibling) > 0) {
570
+ *has_later_siblings = true;
571
+ if (*has_later_named_siblings) break;
572
+ if (sibling.ptr->named_child_count > 0) {
573
+ *has_later_named_siblings = true;
574
+ break;
575
+ }
576
+ }
577
+ if (!ts_subtree_extra(sibling)) structural_child_index++;
578
+ }
579
+ }
580
+
581
+ #undef subtree_symbol
582
+
583
+ if (!ts_subtree_extra(*entry->subtree)) {
584
+ const TSFieldMapEntry *field_map, *field_map_end;
585
+ ts_language_field_map(
586
+ self->tree->language,
587
+ parent_entry->subtree->ptr->production_id,
588
+ &field_map, &field_map_end
589
+ );
590
+
591
+ // Look for a field name associated with the current node.
592
+ if (!*field_id) {
593
+ for (const TSFieldMapEntry *map = field_map; map < field_map_end; map++) {
594
+ if (!map->inherited && map->child_index == entry->structural_child_index) {
595
+ *field_id = map->field_id;
596
+ break;
597
+ }
598
+ }
599
+ }
600
+
601
+ // Determine if the current node can have later siblings with the same field name.
602
+ if (*field_id) {
603
+ for (const TSFieldMapEntry *map = field_map; map < field_map_end; map++) {
604
+ if (
605
+ map->field_id == *field_id &&
606
+ map->child_index > entry->structural_child_index
607
+ ) {
608
+ *can_have_later_siblings_with_this_field = true;
609
+ break;
610
+ }
611
+ }
612
+ }
613
+ }
614
+ }
615
+ }
616
+
617
+ uint32_t ts_tree_cursor_current_depth(const TSTreeCursor *_self) {
618
+ const TreeCursor *self = (const TreeCursor *)_self;
619
+ uint32_t depth = 0;
620
+ for (unsigned i = 1; i < self->stack.size; i++) {
621
+ if (ts_tree_cursor_is_entry_visible(self, i)) {
622
+ depth++;
623
+ }
624
+ }
625
+ return depth;
626
+ }
627
+
628
+ TSNode ts_tree_cursor_parent_node(const TSTreeCursor *_self) {
629
+ const TreeCursor *self = (const TreeCursor *)_self;
630
+ for (int i = (int)self->stack.size - 2; i >= 0; i--) {
631
+ TreeCursorEntry *entry = &self->stack.contents[i];
632
+ bool is_visible = true;
633
+ TSSymbol alias_symbol = 0;
634
+ if (i > 0) {
635
+ TreeCursorEntry *parent_entry = &self->stack.contents[i - 1];
636
+ alias_symbol = ts_language_alias_at(
637
+ self->tree->language,
638
+ parent_entry->subtree->ptr->production_id,
639
+ entry->structural_child_index
640
+ );
641
+ is_visible = (alias_symbol != 0) || ts_subtree_visible(*entry->subtree);
642
+ }
643
+ if (is_visible) {
644
+ return ts_node_new(
645
+ self->tree,
646
+ entry->subtree,
647
+ entry->position,
648
+ alias_symbol
649
+ );
650
+ }
651
+ }
652
+ return ts_node_new(NULL, NULL, length_zero(), 0);
653
+ }
654
+
655
+ TSFieldId ts_tree_cursor_current_field_id(const TSTreeCursor *_self) {
656
+ const TreeCursor *self = (const TreeCursor *)_self;
657
+
658
+ // Walk up the tree, visiting the current node and its invisible ancestors.
659
+ for (unsigned i = self->stack.size - 1; i > 0; i--) {
660
+ TreeCursorEntry *entry = &self->stack.contents[i];
661
+ TreeCursorEntry *parent_entry = &self->stack.contents[i - 1];
662
+
663
+ // Stop walking up when another visible node is found.
664
+ if (
665
+ i != self->stack.size - 1 &&
666
+ ts_tree_cursor_is_entry_visible(self, i)
667
+ ) break;
668
+
669
+ if (ts_subtree_extra(*entry->subtree)) break;
670
+
671
+ const TSFieldMapEntry *field_map, *field_map_end;
672
+ ts_language_field_map(
673
+ self->tree->language,
674
+ parent_entry->subtree->ptr->production_id,
675
+ &field_map, &field_map_end
676
+ );
677
+ for (const TSFieldMapEntry *map = field_map; map < field_map_end; map++) {
678
+ if (!map->inherited && map->child_index == entry->structural_child_index) {
679
+ return map->field_id;
680
+ }
681
+ }
682
+ }
683
+ return 0;
684
+ }
685
+
686
+ const char *ts_tree_cursor_current_field_name(const TSTreeCursor *_self) {
687
+ TSFieldId id = ts_tree_cursor_current_field_id(_self);
688
+ if (id) {
689
+ const TreeCursor *self = (const TreeCursor *)_self;
690
+ return self->tree->language->field_names[id];
691
+ } else {
692
+ return NULL;
693
+ }
694
+ }
695
+
696
+ TSTreeCursor ts_tree_cursor_copy(const TSTreeCursor *_cursor) {
697
+ const TreeCursor *cursor = (const TreeCursor *)_cursor;
698
+ TSTreeCursor res = {NULL, NULL, {0, 0}};
699
+ TreeCursor *copy = (TreeCursor *)&res;
700
+ copy->tree = cursor->tree;
701
+ copy->root_alias_symbol = cursor->root_alias_symbol;
702
+ array_init(&copy->stack);
703
+ array_push_all(&copy->stack, &cursor->stack);
704
+ return res;
705
+ }
706
+
707
+ void ts_tree_cursor_reset_to(TSTreeCursor *_dst, const TSTreeCursor *_src) {
708
+ const TreeCursor *cursor = (const TreeCursor *)_src;
709
+ TreeCursor *copy = (TreeCursor *)_dst;
710
+ copy->tree = cursor->tree;
711
+ copy->root_alias_symbol = cursor->root_alias_symbol;
712
+ array_clear(&copy->stack);
713
+ array_push_all(&copy->stack, &cursor->stack);
714
+ }