@feiyoug/skill-lab 0.0.0 → 0.0.2

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 (465) hide show
  1. package/README.md +73 -0
  2. package/esm/analyzer/astgrep/client.d.ts +20 -8
  3. package/esm/analyzer/astgrep/client.d.ts.map +1 -1
  4. package/esm/analyzer/astgrep/client.js +58 -31
  5. package/esm/analyzer/config/default.d.ts +8 -0
  6. package/esm/analyzer/config/default.d.ts.map +1 -0
  7. package/esm/analyzer/config/default.js +91 -0
  8. package/esm/analyzer/config/helpers.d.ts +8 -0
  9. package/esm/analyzer/config/helpers.d.ts.map +1 -0
  10. package/esm/analyzer/config/helpers.js +72 -0
  11. package/esm/analyzer/config/mod.d.ts +4 -0
  12. package/esm/analyzer/config/mod.d.ts.map +1 -0
  13. package/esm/analyzer/config/mod.js +3 -0
  14. package/esm/analyzer/config/types.d.ts +58 -0
  15. package/esm/analyzer/config/types.d.ts.map +1 -0
  16. package/esm/analyzer/{config.js → config/types.js} +0 -28
  17. package/esm/analyzer/logging.d.ts +3 -0
  18. package/esm/analyzer/logging.d.ts.map +1 -0
  19. package/esm/analyzer/logging.js +6 -0
  20. package/esm/analyzer/mod.d.ts +12 -5
  21. package/esm/analyzer/mod.d.ts.map +1 -1
  22. package/esm/analyzer/mod.js +25 -12
  23. package/esm/analyzer/result.d.ts +35 -0
  24. package/esm/analyzer/result.d.ts.map +1 -0
  25. package/esm/analyzer/result.js +311 -0
  26. package/esm/analyzer/rules/bash/commands/mod.d.ts +1 -0
  27. package/esm/analyzer/rules/bash/commands/mod.d.ts.map +1 -1
  28. package/esm/analyzer/rules/bash/commands/mod.js +3 -0
  29. package/esm/analyzer/rules/bash/commands/pip.d.ts +3 -0
  30. package/esm/analyzer/rules/bash/commands/pip.d.ts.map +1 -0
  31. package/esm/analyzer/rules/bash/commands/pip.js +14 -0
  32. package/esm/analyzer/rules/bash/extractFileRefs.d.ts +1 -1
  33. package/esm/analyzer/rules/bash/extractFileRefs.d.ts.map +1 -1
  34. package/esm/analyzer/rules/bash/extractFileRefs.js +2 -2
  35. package/esm/analyzer/rules/bash/inline-command-classifier.d.ts +1 -1
  36. package/esm/analyzer/rules/bash/inline-command-classifier.d.ts.map +1 -1
  37. package/esm/analyzer/rules/bash/inline-command-classifier.js +4 -4
  38. package/esm/analyzer/rules/javascript/extractFileRefs.d.ts +3 -4
  39. package/esm/analyzer/rules/javascript/extractFileRefs.d.ts.map +1 -1
  40. package/esm/analyzer/rules/javascript/extractFileRefs.js +3 -4
  41. package/esm/analyzer/rules/markdown/extractCodeBlocks.d.ts.map +1 -1
  42. package/esm/analyzer/rules/markdown/extractCodeBlocks.js +6 -3
  43. package/esm/analyzer/rules/markdown/extractFileRefs.d.ts.map +1 -1
  44. package/esm/analyzer/rules/markdown/extractFileRefs.js +2 -0
  45. package/esm/analyzer/rules/python/extractFileRefs.d.ts +1 -1
  46. package/esm/analyzer/rules/python/extractFileRefs.d.ts.map +1 -1
  47. package/esm/analyzer/rules/python/extractFileRefs.js +2 -2
  48. package/esm/analyzer/steps/001-discovery/discover-files.d.ts +4 -0
  49. package/esm/analyzer/steps/001-discovery/discover-files.d.ts.map +1 -1
  50. package/esm/analyzer/steps/001-discovery/discover-files.js +18 -2
  51. package/esm/analyzer/steps/001-discovery/mod.d.ts.map +1 -1
  52. package/esm/analyzer/steps/001-discovery/mod.js +39 -9
  53. package/esm/analyzer/steps/002-permissions/mod.d.ts.map +1 -1
  54. package/esm/analyzer/steps/002-permissions/mod.js +156 -73
  55. package/esm/analyzer/steps/002-permissions/scan-file.d.ts +1 -1
  56. package/esm/analyzer/steps/002-permissions/scan-file.d.ts.map +1 -1
  57. package/esm/analyzer/steps/002-permissions/scan-file.js +40 -5
  58. package/esm/analyzer/steps/002-permissions/seed-frontmatter.js +2 -2
  59. package/esm/analyzer/steps/003-risks/dep-risks.d.ts +3 -0
  60. package/esm/analyzer/steps/003-risks/dep-risks.d.ts.map +1 -0
  61. package/esm/analyzer/steps/003-risks/dep-risks.js +74 -0
  62. package/esm/analyzer/steps/003-risks/helpers.d.ts +1 -0
  63. package/esm/analyzer/steps/003-risks/helpers.d.ts.map +1 -1
  64. package/esm/analyzer/steps/003-risks/helpers.js +1 -0
  65. package/esm/analyzer/steps/003-risks/mod.d.ts +3 -2
  66. package/esm/analyzer/steps/003-risks/mod.d.ts.map +1 -1
  67. package/esm/analyzer/steps/003-risks/mod.js +41 -4
  68. package/esm/analyzer/steps/003-risks/policy.d.ts +7 -0
  69. package/esm/analyzer/steps/003-risks/policy.d.ts.map +1 -0
  70. package/esm/analyzer/steps/003-risks/policy.js +23 -0
  71. package/esm/analyzer/steps/003-risks/rule-mapped.d.ts +2 -2
  72. package/esm/analyzer/steps/003-risks/rule-mapped.d.ts.map +1 -1
  73. package/esm/analyzer/steps/003-risks/rule-mapped.js +83 -2
  74. package/esm/analyzer/steps/003-risks/scoring.d.ts +9 -1
  75. package/esm/analyzer/steps/003-risks/scoring.d.ts.map +1 -1
  76. package/esm/analyzer/steps/003-risks/scoring.js +55 -42
  77. package/esm/analyzer/treesitter/client.d.ts +31 -0
  78. package/esm/analyzer/treesitter/client.d.ts.map +1 -0
  79. package/esm/analyzer/{treesiter → treesitter}/client.js +43 -39
  80. package/esm/analyzer/treesitter/registry.d.ts +73 -0
  81. package/esm/analyzer/treesitter/registry.d.ts.map +1 -0
  82. package/esm/analyzer/treesitter/registry.js +165 -0
  83. package/esm/analyzer/types.d.ts +14 -28
  84. package/esm/analyzer/types.d.ts.map +1 -1
  85. package/esm/deps/jsr.io/@deno-library/progress/1.5.1/deps.d.ts +3 -0
  86. package/esm/deps/jsr.io/@deno-library/progress/1.5.1/deps.d.ts.map +1 -0
  87. package/esm/deps/jsr.io/@deno-library/progress/1.5.1/deps.js +3 -0
  88. package/esm/deps/jsr.io/@deno-library/progress/1.5.1/mod.d.ts +93 -0
  89. package/esm/deps/jsr.io/@deno-library/progress/1.5.1/mod.d.ts.map +1 -0
  90. package/esm/deps/jsr.io/@deno-library/progress/1.5.1/mod.js +297 -0
  91. package/esm/deps/jsr.io/@deno-library/progress/1.5.1/multi.d.ts +84 -0
  92. package/esm/deps/jsr.io/@deno-library/progress/1.5.1/multi.d.ts.map +1 -0
  93. package/esm/deps/jsr.io/@deno-library/progress/1.5.1/multi.js +268 -0
  94. package/esm/deps/jsr.io/@deno-library/progress/1.5.1/time.d.ts +18 -0
  95. package/esm/deps/jsr.io/@deno-library/progress/1.5.1/time.d.ts.map +1 -0
  96. package/esm/deps/jsr.io/@deno-library/progress/1.5.1/time.js +45 -0
  97. package/esm/deps/jsr.io/@std/fmt/1.0.3/colors.d.ts +700 -0
  98. package/esm/deps/jsr.io/@std/fmt/1.0.3/colors.d.ts.map +1 -0
  99. package/esm/deps/jsr.io/@std/fmt/1.0.3/colors.js +903 -0
  100. package/esm/deps/jsr.io/@std/io/0.225.0/types.d.ts +146 -0
  101. package/esm/deps/jsr.io/@std/io/0.225.0/types.d.ts.map +1 -0
  102. package/esm/deps/jsr.io/@std/io/0.225.0/types.js +15 -0
  103. package/esm/deps/jsr.io/@std/io/0.225.0/write_all.d.ts +51 -0
  104. package/esm/deps/jsr.io/@std/io/0.225.0/write_all.d.ts.map +1 -0
  105. package/esm/deps/jsr.io/@std/io/0.225.0/write_all.js +61 -0
  106. package/esm/shared/deep_merge.d.ts +12 -0
  107. package/esm/shared/deep_merge.d.ts.map +1 -0
  108. package/esm/shared/deep_merge.js +49 -0
  109. package/esm/shared/mod.d.ts +1 -0
  110. package/esm/shared/mod.d.ts.map +1 -1
  111. package/esm/shared/mod.js +1 -0
  112. package/esm/shared/types/filetypes.d.ts +2 -2
  113. package/esm/shared/types/filetypes.d.ts.map +1 -1
  114. package/esm/shared/types/permissions.d.ts +1 -1
  115. package/esm/shared/types/permissions.d.ts.map +1 -1
  116. package/esm/shared/types/risks.d.ts +4 -1
  117. package/esm/shared/types/risks.d.ts.map +1 -1
  118. package/esm/skillreader/types.d.ts +2 -2
  119. package/esm/skillreader/types.d.ts.map +1 -1
  120. package/esm/skillreader/types.js +2 -2
  121. package/package.json +1 -1
  122. package/script/analyzer/astgrep/client.d.ts +20 -8
  123. package/script/analyzer/astgrep/client.d.ts.map +1 -1
  124. package/script/analyzer/astgrep/client.js +58 -64
  125. package/script/analyzer/config/default.d.ts +8 -0
  126. package/script/analyzer/config/default.d.ts.map +1 -0
  127. package/script/analyzer/config/default.js +94 -0
  128. package/script/analyzer/config/helpers.d.ts +8 -0
  129. package/script/analyzer/config/helpers.d.ts.map +1 -0
  130. package/script/analyzer/config/helpers.js +76 -0
  131. package/script/analyzer/config/mod.d.ts +4 -0
  132. package/script/analyzer/config/mod.d.ts.map +1 -0
  133. package/script/analyzer/config/mod.js +21 -0
  134. package/script/analyzer/config/types.d.ts +58 -0
  135. package/script/analyzer/config/types.d.ts.map +1 -0
  136. package/script/analyzer/{config.js → config/types.js} +1 -29
  137. package/script/analyzer/logging.d.ts +3 -0
  138. package/script/analyzer/logging.d.ts.map +1 -0
  139. package/script/analyzer/logging.js +9 -0
  140. package/script/analyzer/mod.d.ts +12 -5
  141. package/script/analyzer/mod.d.ts.map +1 -1
  142. package/script/analyzer/mod.js +35 -20
  143. package/script/analyzer/result.d.ts +35 -0
  144. package/script/analyzer/result.d.ts.map +1 -0
  145. package/script/analyzer/result.js +315 -0
  146. package/script/analyzer/rules/bash/commands/mod.d.ts +1 -0
  147. package/script/analyzer/rules/bash/commands/mod.d.ts.map +1 -1
  148. package/script/analyzer/rules/bash/commands/mod.js +3 -0
  149. package/script/analyzer/rules/bash/commands/pip.d.ts +3 -0
  150. package/script/analyzer/rules/bash/commands/pip.d.ts.map +1 -0
  151. package/script/analyzer/rules/bash/commands/pip.js +17 -0
  152. package/script/analyzer/rules/bash/extractFileRefs.d.ts +1 -1
  153. package/script/analyzer/rules/bash/extractFileRefs.d.ts.map +1 -1
  154. package/script/analyzer/rules/bash/extractFileRefs.js +2 -2
  155. package/script/analyzer/rules/bash/inline-command-classifier.d.ts +1 -1
  156. package/script/analyzer/rules/bash/inline-command-classifier.d.ts.map +1 -1
  157. package/script/analyzer/rules/bash/inline-command-classifier.js +4 -4
  158. package/script/analyzer/rules/javascript/extractFileRefs.d.ts +3 -4
  159. package/script/analyzer/rules/javascript/extractFileRefs.d.ts.map +1 -1
  160. package/script/analyzer/rules/javascript/extractFileRefs.js +3 -4
  161. package/script/analyzer/rules/markdown/extractCodeBlocks.d.ts.map +1 -1
  162. package/script/analyzer/rules/markdown/extractCodeBlocks.js +6 -3
  163. package/script/analyzer/rules/markdown/extractFileRefs.d.ts.map +1 -1
  164. package/script/analyzer/rules/markdown/extractFileRefs.js +2 -0
  165. package/script/analyzer/rules/python/extractFileRefs.d.ts +1 -1
  166. package/script/analyzer/rules/python/extractFileRefs.d.ts.map +1 -1
  167. package/script/analyzer/rules/python/extractFileRefs.js +2 -2
  168. package/script/analyzer/steps/001-discovery/discover-files.d.ts +4 -0
  169. package/script/analyzer/steps/001-discovery/discover-files.d.ts.map +1 -1
  170. package/script/analyzer/steps/001-discovery/discover-files.js +18 -2
  171. package/script/analyzer/steps/001-discovery/mod.d.ts.map +1 -1
  172. package/script/analyzer/steps/001-discovery/mod.js +77 -11
  173. package/script/analyzer/steps/002-permissions/mod.d.ts.map +1 -1
  174. package/script/analyzer/steps/002-permissions/mod.js +194 -75
  175. package/script/analyzer/steps/002-permissions/scan-file.d.ts +1 -1
  176. package/script/analyzer/steps/002-permissions/scan-file.d.ts.map +1 -1
  177. package/script/analyzer/steps/002-permissions/scan-file.js +40 -5
  178. package/script/analyzer/steps/002-permissions/seed-frontmatter.js +3 -3
  179. package/script/analyzer/steps/003-risks/dep-risks.d.ts +3 -0
  180. package/script/analyzer/steps/003-risks/dep-risks.d.ts.map +1 -0
  181. package/script/analyzer/steps/003-risks/dep-risks.js +77 -0
  182. package/script/analyzer/steps/003-risks/helpers.d.ts +1 -0
  183. package/script/analyzer/steps/003-risks/helpers.d.ts.map +1 -1
  184. package/script/analyzer/steps/003-risks/helpers.js +1 -0
  185. package/script/analyzer/steps/003-risks/mod.d.ts +3 -2
  186. package/script/analyzer/steps/003-risks/mod.d.ts.map +1 -1
  187. package/script/analyzer/steps/003-risks/mod.js +77 -4
  188. package/script/analyzer/steps/003-risks/policy.d.ts +7 -0
  189. package/script/analyzer/steps/003-risks/policy.d.ts.map +1 -0
  190. package/script/analyzer/steps/003-risks/policy.js +29 -0
  191. package/script/analyzer/steps/003-risks/rule-mapped.d.ts +2 -2
  192. package/script/analyzer/steps/003-risks/rule-mapped.d.ts.map +1 -1
  193. package/script/analyzer/steps/003-risks/rule-mapped.js +83 -2
  194. package/script/analyzer/steps/003-risks/scoring.d.ts +9 -1
  195. package/script/analyzer/steps/003-risks/scoring.d.ts.map +1 -1
  196. package/script/analyzer/steps/003-risks/scoring.js +55 -42
  197. package/script/analyzer/treesitter/client.d.ts +31 -0
  198. package/script/analyzer/treesitter/client.d.ts.map +1 -0
  199. package/script/analyzer/treesitter/client.js +136 -0
  200. package/script/analyzer/treesitter/registry.d.ts +73 -0
  201. package/script/analyzer/treesitter/registry.d.ts.map +1 -0
  202. package/script/analyzer/treesitter/registry.js +206 -0
  203. package/script/analyzer/types.d.ts +14 -28
  204. package/script/analyzer/types.d.ts.map +1 -1
  205. package/script/deps/jsr.io/@deno-library/progress/1.5.1/deps.d.ts +3 -0
  206. package/script/deps/jsr.io/@deno-library/progress/1.5.1/deps.d.ts.map +1 -0
  207. package/script/deps/jsr.io/@deno-library/progress/1.5.1/deps.js +10 -0
  208. package/script/deps/jsr.io/@deno-library/progress/1.5.1/mod.d.ts +93 -0
  209. package/script/deps/jsr.io/@deno-library/progress/1.5.1/mod.d.ts.map +1 -0
  210. package/script/deps/jsr.io/@deno-library/progress/1.5.1/mod.js +334 -0
  211. package/script/deps/jsr.io/@deno-library/progress/1.5.1/multi.d.ts +84 -0
  212. package/script/deps/jsr.io/@deno-library/progress/1.5.1/multi.d.ts.map +1 -0
  213. package/script/deps/jsr.io/@deno-library/progress/1.5.1/multi.js +305 -0
  214. package/script/deps/jsr.io/@deno-library/progress/1.5.1/time.d.ts +18 -0
  215. package/script/deps/jsr.io/@deno-library/progress/1.5.1/time.d.ts.map +1 -0
  216. package/script/deps/jsr.io/@deno-library/progress/1.5.1/time.js +48 -0
  217. package/script/deps/jsr.io/@std/fmt/1.0.3/colors.d.ts +700 -0
  218. package/script/deps/jsr.io/@std/fmt/1.0.3/colors.d.ts.map +1 -0
  219. package/script/deps/jsr.io/@std/fmt/1.0.3/colors.js +986 -0
  220. package/script/deps/jsr.io/@std/io/0.225.0/types.d.ts +146 -0
  221. package/script/deps/jsr.io/@std/io/0.225.0/types.d.ts.map +1 -0
  222. package/script/deps/jsr.io/@std/io/0.225.0/types.js +18 -0
  223. package/script/deps/jsr.io/@std/io/0.225.0/write_all.d.ts +51 -0
  224. package/script/deps/jsr.io/@std/io/0.225.0/write_all.d.ts.map +1 -0
  225. package/script/deps/jsr.io/@std/io/0.225.0/write_all.js +65 -0
  226. package/script/shared/deep_merge.d.ts +12 -0
  227. package/script/shared/deep_merge.d.ts.map +1 -0
  228. package/script/shared/deep_merge.js +53 -0
  229. package/script/shared/mod.d.ts +1 -0
  230. package/script/shared/mod.d.ts.map +1 -1
  231. package/script/shared/mod.js +1 -0
  232. package/script/shared/types/filetypes.d.ts +2 -2
  233. package/script/shared/types/filetypes.d.ts.map +1 -1
  234. package/script/shared/types/permissions.d.ts +1 -1
  235. package/script/shared/types/permissions.d.ts.map +1 -1
  236. package/script/shared/types/risks.d.ts +4 -1
  237. package/script/shared/types/risks.d.ts.map +1 -1
  238. package/script/skillreader/types.d.ts +2 -2
  239. package/script/skillreader/types.d.ts.map +1 -1
  240. package/script/skillreader/types.js +2 -2
  241. package/src/_dnt.polyfills.ts +27 -0
  242. package/src/_dnt.shims.ts +64 -0
  243. package/src/analyzer/astgrep/client.ts +184 -0
  244. package/src/analyzer/astgrep/mod.ts +2 -0
  245. package/src/analyzer/config/default.ts +98 -0
  246. package/src/analyzer/config/helpers.ts +107 -0
  247. package/src/analyzer/config/mod.ts +3 -0
  248. package/src/analyzer/config/types.ts +103 -0
  249. package/src/analyzer/logging.ts +8 -0
  250. package/src/analyzer/mod.ts +118 -0
  251. package/src/analyzer/result.ts +393 -0
  252. package/src/analyzer/rules/bash/astTypes.ts +5 -0
  253. package/src/analyzer/rules/bash/commands/bd.ts +23 -0
  254. package/src/analyzer/rules/bash/commands/cron.ts +21 -0
  255. package/src/analyzer/rules/bash/commands/docker.ts +37 -0
  256. package/src/analyzer/rules/bash/commands/eval.ts +52 -0
  257. package/src/analyzer/rules/bash/commands/generic.ts +16 -0
  258. package/src/analyzer/rules/bash/commands/gh.ts +21 -0
  259. package/src/analyzer/rules/bash/commands/git.ts +28 -0
  260. package/src/analyzer/rules/bash/commands/mod.ts +38 -0
  261. package/src/analyzer/rules/bash/commands/node.ts +64 -0
  262. package/src/analyzer/rules/bash/commands/openspec.ts +16 -0
  263. package/src/analyzer/rules/bash/commands/pip.ts +16 -0
  264. package/src/analyzer/rules/bash/commands/sudo.ts +21 -0
  265. package/src/analyzer/rules/bash/destructive.ts +28 -0
  266. package/src/analyzer/rules/bash/extractFileRefs.ts +101 -0
  267. package/src/analyzer/rules/bash/filesystem.ts +50 -0
  268. package/src/analyzer/rules/bash/injection.ts +21 -0
  269. package/src/analyzer/rules/bash/inline-command-classifier.ts +94 -0
  270. package/src/analyzer/rules/bash/mod.ts +23 -0
  271. package/src/analyzer/rules/bash/network.ts +64 -0
  272. package/src/analyzer/rules/bash/secret-detection.ts +43 -0
  273. package/src/analyzer/rules/javascript/astTypes.ts +8 -0
  274. package/src/analyzer/rules/javascript/extractFileRefs.ts +131 -0
  275. package/src/analyzer/rules/javascript/filesystem.ts +28 -0
  276. package/src/analyzer/rules/javascript/injection.ts +21 -0
  277. package/src/analyzer/rules/javascript/mod.ts +26 -0
  278. package/src/analyzer/rules/javascript/network.ts +27 -0
  279. package/src/analyzer/rules/javascript/secret-detection.ts +68 -0
  280. package/src/analyzer/rules/javascript/subprocess.ts +16 -0
  281. package/src/analyzer/rules/markdown/astTypes.ts +35 -0
  282. package/src/analyzer/rules/markdown/extractCodeBlocks.ts +101 -0
  283. package/src/analyzer/rules/markdown/extractFileRefs.ts +179 -0
  284. package/src/analyzer/rules/markdown/mod.ts +12 -0
  285. package/src/analyzer/rules/mod.ts +77 -0
  286. package/src/analyzer/rules/python/astTypes.ts +9 -0
  287. package/src/analyzer/rules/python/extractFileRefs.ts +92 -0
  288. package/src/analyzer/rules/python/mod.ts +15 -0
  289. package/src/analyzer/rules/python/network.ts +26 -0
  290. package/src/analyzer/rules/python/secret-detection.ts +30 -0
  291. package/src/analyzer/rules/shared/file-refs.ts +38 -0
  292. package/src/analyzer/rules/shared/network-evaluators.ts +107 -0
  293. package/src/analyzer/rules/shared/prompt-injection.ts +48 -0
  294. package/src/analyzer/rules/shared/secret-evaluators.ts +13 -0
  295. package/src/analyzer/rules/text/mod.ts +12 -0
  296. package/src/analyzer/rules/typescript/mod.ts +7 -0
  297. package/src/analyzer/steps/001-discovery/discover-files.ts +211 -0
  298. package/src/analyzer/steps/001-discovery/filter-files.ts +72 -0
  299. package/src/analyzer/steps/001-discovery/mod.ts +103 -0
  300. package/src/analyzer/steps/002-permissions/mod.ts +329 -0
  301. package/src/analyzer/steps/002-permissions/scan-file.ts +258 -0
  302. package/src/analyzer/steps/002-permissions/seed-frontmatter.ts +66 -0
  303. package/src/analyzer/steps/002-permissions/synthesize.ts +42 -0
  304. package/src/analyzer/steps/003-risks/dep-risks.ts +89 -0
  305. package/src/analyzer/steps/003-risks/helpers.ts +41 -0
  306. package/src/analyzer/steps/003-risks/mod.ts +86 -0
  307. package/src/analyzer/steps/003-risks/policy.ts +38 -0
  308. package/src/analyzer/steps/003-risks/rule-mapped.ts +206 -0
  309. package/src/analyzer/steps/003-risks/scoring.ts +117 -0
  310. package/src/analyzer/steps/mod.ts +3 -0
  311. package/src/analyzer/treesitter/client.ts +120 -0
  312. package/src/analyzer/treesitter/registry.ts +198 -0
  313. package/src/analyzer/types.ts +78 -0
  314. package/src/analyzer/utils/code-block-path.ts +33 -0
  315. package/src/analyzer/utils/id-generator.ts +59 -0
  316. package/src/analyzer/utils/secret-validator.ts +29 -0
  317. package/src/analyzer/utils/url-parser.ts +25 -0
  318. package/src/deps/jsr.io/@deno-library/progress/1.5.1/deps.ts +3 -0
  319. package/src/deps/jsr.io/@deno-library/progress/1.5.1/mod.ts +265 -0
  320. package/src/deps/jsr.io/@deno-library/progress/1.5.1/multi.ts +250 -0
  321. package/src/deps/jsr.io/@deno-library/progress/1.5.1/time.ts +69 -0
  322. package/src/deps/jsr.io/@std/fmt/1.0.3/colors.ts +1004 -0
  323. package/src/deps/jsr.io/@std/internal/1.0.12/_os.ts +15 -0
  324. package/src/deps/jsr.io/@std/internal/1.0.12/os.ts +7 -0
  325. package/src/deps/jsr.io/@std/io/0.225.0/types.ts +157 -0
  326. package/src/deps/jsr.io/@std/io/0.225.0/write_all.ts +65 -0
  327. package/src/deps/jsr.io/@std/path/1.1.4/_common/assert_path.ts +10 -0
  328. package/src/deps/jsr.io/@std/path/1.1.4/_common/basename.ts +53 -0
  329. package/src/deps/jsr.io/@std/path/1.1.4/_common/common.ts +26 -0
  330. package/src/deps/jsr.io/@std/path/1.1.4/_common/constants.ts +49 -0
  331. package/src/deps/jsr.io/@std/path/1.1.4/_common/dirname.ts +9 -0
  332. package/src/deps/jsr.io/@std/path/1.1.4/_common/format.ts +25 -0
  333. package/src/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.ts +12 -0
  334. package/src/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.ts +295 -0
  335. package/src/deps/jsr.io/@std/path/1.1.4/_common/normalize.ts +9 -0
  336. package/src/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.ts +74 -0
  337. package/src/deps/jsr.io/@std/path/1.1.4/_common/relative.ts +10 -0
  338. package/src/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.ts +25 -0
  339. package/src/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.ts +17 -0
  340. package/src/deps/jsr.io/@std/path/1.1.4/basename.ts +37 -0
  341. package/src/deps/jsr.io/@std/path/1.1.4/common.ts +35 -0
  342. package/src/deps/jsr.io/@std/path/1.1.4/constants.ts +18 -0
  343. package/src/deps/jsr.io/@std/path/1.1.4/dirname.ts +30 -0
  344. package/src/deps/jsr.io/@std/path/1.1.4/extname.ts +29 -0
  345. package/src/deps/jsr.io/@std/path/1.1.4/format.ts +30 -0
  346. package/src/deps/jsr.io/@std/path/1.1.4/from_file_url.ts +30 -0
  347. package/src/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.ts +94 -0
  348. package/src/deps/jsr.io/@std/path/1.1.4/is_absolute.ts +30 -0
  349. package/src/deps/jsr.io/@std/path/1.1.4/is_glob.ts +49 -0
  350. package/src/deps/jsr.io/@std/path/1.1.4/join.ts +31 -0
  351. package/src/deps/jsr.io/@std/path/1.1.4/join_globs.ts +42 -0
  352. package/src/deps/jsr.io/@std/path/1.1.4/mod.ts +217 -0
  353. package/src/deps/jsr.io/@std/path/1.1.4/normalize.ts +33 -0
  354. package/src/deps/jsr.io/@std/path/1.1.4/normalize_glob.ts +45 -0
  355. package/src/deps/jsr.io/@std/path/1.1.4/parse.ts +44 -0
  356. package/src/deps/jsr.io/@std/path/1.1.4/posix/_util.ts +10 -0
  357. package/src/deps/jsr.io/@std/path/1.1.4/posix/basename.ts +62 -0
  358. package/src/deps/jsr.io/@std/path/1.1.4/posix/constants.ts +15 -0
  359. package/src/deps/jsr.io/@std/path/1.1.4/posix/dirname.ts +72 -0
  360. package/src/deps/jsr.io/@std/path/1.1.4/posix/extname.ts +96 -0
  361. package/src/deps/jsr.io/@std/path/1.1.4/posix/format.ts +31 -0
  362. package/src/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.ts +25 -0
  363. package/src/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.ts +94 -0
  364. package/src/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.ts +25 -0
  365. package/src/deps/jsr.io/@std/path/1.1.4/posix/join.ts +46 -0
  366. package/src/deps/jsr.io/@std/path/1.1.4/posix/join_globs.ts +45 -0
  367. package/src/deps/jsr.io/@std/path/1.1.4/posix/normalize.ts +63 -0
  368. package/src/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.ts +43 -0
  369. package/src/deps/jsr.io/@std/path/1.1.4/posix/parse.ts +121 -0
  370. package/src/deps/jsr.io/@std/path/1.1.4/posix/relative.ts +103 -0
  371. package/src/deps/jsr.io/@std/path/1.1.4/posix/resolve.ts +71 -0
  372. package/src/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.ts +32 -0
  373. package/src/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.ts +21 -0
  374. package/src/deps/jsr.io/@std/path/1.1.4/relative.ts +32 -0
  375. package/src/deps/jsr.io/@std/path/1.1.4/resolve.ts +32 -0
  376. package/src/deps/jsr.io/@std/path/1.1.4/to_file_url.ts +30 -0
  377. package/src/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.ts +31 -0
  378. package/src/deps/jsr.io/@std/path/1.1.4/types.ts +40 -0
  379. package/src/deps/jsr.io/@std/path/1.1.4/windows/_util.ts +28 -0
  380. package/src/deps/jsr.io/@std/path/1.1.4/windows/basename.ts +54 -0
  381. package/src/deps/jsr.io/@std/path/1.1.4/windows/constants.ts +15 -0
  382. package/src/deps/jsr.io/@std/path/1.1.4/windows/dirname.ts +118 -0
  383. package/src/deps/jsr.io/@std/path/1.1.4/windows/extname.ts +90 -0
  384. package/src/deps/jsr.io/@std/path/1.1.4/windows/format.ts +31 -0
  385. package/src/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.ts +34 -0
  386. package/src/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.ts +92 -0
  387. package/src/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.ts +40 -0
  388. package/src/deps/jsr.io/@std/path/1.1.4/windows/join.ts +78 -0
  389. package/src/deps/jsr.io/@std/path/1.1.4/windows/join_globs.ts +46 -0
  390. package/src/deps/jsr.io/@std/path/1.1.4/windows/normalize.ts +136 -0
  391. package/src/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.ts +43 -0
  392. package/src/deps/jsr.io/@std/path/1.1.4/windows/parse.ts +184 -0
  393. package/src/deps/jsr.io/@std/path/1.1.4/windows/relative.ts +128 -0
  394. package/src/deps/jsr.io/@std/path/1.1.4/windows/resolve.ts +178 -0
  395. package/src/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.ts +38 -0
  396. package/src/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.ts +60 -0
  397. package/src/deps/jsr.io/@std/yaml/1.0.11/_chars.ts +55 -0
  398. package/src/deps/jsr.io/@std/yaml/1.0.11/_dumper_state.ts +841 -0
  399. package/src/deps/jsr.io/@std/yaml/1.0.11/_loader_state.ts +1780 -0
  400. package/src/deps/jsr.io/@std/yaml/1.0.11/_schema.ts +183 -0
  401. package/src/deps/jsr.io/@std/yaml/1.0.11/_type/binary.ts +127 -0
  402. package/src/deps/jsr.io/@std/yaml/1.0.11/_type/bool.ts +37 -0
  403. package/src/deps/jsr.io/@std/yaml/1.0.11/_type/float.ts +112 -0
  404. package/src/deps/jsr.io/@std/yaml/1.0.11/_type/int.ts +174 -0
  405. package/src/deps/jsr.io/@std/yaml/1.0.11/_type/map.ts +17 -0
  406. package/src/deps/jsr.io/@std/yaml/1.0.11/_type/merge.ts +13 -0
  407. package/src/deps/jsr.io/@std/yaml/1.0.11/_type/nil.ts +27 -0
  408. package/src/deps/jsr.io/@std/yaml/1.0.11/_type/omap.ts +30 -0
  409. package/src/deps/jsr.io/@std/yaml/1.0.11/_type/pairs.ts +22 -0
  410. package/src/deps/jsr.io/@std/yaml/1.0.11/_type/regexp.ts +33 -0
  411. package/src/deps/jsr.io/@std/yaml/1.0.11/_type/seq.ts +13 -0
  412. package/src/deps/jsr.io/@std/yaml/1.0.11/_type/set.ts +17 -0
  413. package/src/deps/jsr.io/@std/yaml/1.0.11/_type/str.ts +12 -0
  414. package/src/deps/jsr.io/@std/yaml/1.0.11/_type/timestamp.ts +101 -0
  415. package/src/deps/jsr.io/@std/yaml/1.0.11/_type/undefined.ts +23 -0
  416. package/src/deps/jsr.io/@std/yaml/1.0.11/_type.ts +49 -0
  417. package/src/deps/jsr.io/@std/yaml/1.0.11/_utils.ts +16 -0
  418. package/src/deps/jsr.io/@std/yaml/1.0.11/mod.ts +54 -0
  419. package/src/deps/jsr.io/@std/yaml/1.0.11/parse.ts +128 -0
  420. package/src/deps/jsr.io/@std/yaml/1.0.11/stringify.ts +118 -0
  421. package/src/shared/deep_merge.ts +73 -0
  422. package/src/shared/mod.ts +2 -0
  423. package/src/shared/types/filetypes.ts +101 -0
  424. package/src/shared/types/findings.ts +7 -0
  425. package/src/shared/types/mod.ts +6 -0
  426. package/src/shared/types/permissions.ts +17 -0
  427. package/src/shared/types/references.ts +62 -0
  428. package/src/shared/types/risks.ts +72 -0
  429. package/src/shared/types/syntaxNode.ts +7 -0
  430. package/src/skillreader/cloudStorage/mod.ts +170 -0
  431. package/src/skillreader/factory.ts +71 -0
  432. package/src/skillreader/fs/git.ts +153 -0
  433. package/src/skillreader/fs/mod.ts +84 -0
  434. package/src/skillreader/github/base.ts +162 -0
  435. package/src/skillreader/github/githubApi.ts +40 -0
  436. package/src/skillreader/github/githubRaw.ts +24 -0
  437. package/src/skillreader/github/mod.ts +45 -0
  438. package/src/skillreader/github/utils.ts +40 -0
  439. package/src/skillreader/manifest.ts +67 -0
  440. package/src/skillreader/mod.ts +26 -0
  441. package/src/skillreader/types.ts +150 -0
  442. package/src/skillreader/utils/frontmatter-parser.ts +72 -0
  443. package/src/skillreader/utils/http-range.ts +38 -0
  444. package/src/skillreader/utils/mod.ts +12 -0
  445. package/esm/analyzer/astgrep/registry.d.ts +0 -18
  446. package/esm/analyzer/astgrep/registry.d.ts.map +0 -1
  447. package/esm/analyzer/astgrep/registry.js +0 -71
  448. package/esm/analyzer/config.d.ts +0 -27
  449. package/esm/analyzer/config.d.ts.map +0 -1
  450. package/esm/analyzer/steps/003-risks/output.d.ts +0 -3
  451. package/esm/analyzer/steps/003-risks/output.d.ts.map +0 -1
  452. package/esm/analyzer/steps/003-risks/output.js +0 -16
  453. package/esm/analyzer/treesiter/client.d.ts +0 -26
  454. package/esm/analyzer/treesiter/client.d.ts.map +0 -1
  455. package/script/analyzer/astgrep/registry.d.ts +0 -18
  456. package/script/analyzer/astgrep/registry.d.ts.map +0 -1
  457. package/script/analyzer/astgrep/registry.js +0 -109
  458. package/script/analyzer/config.d.ts +0 -27
  459. package/script/analyzer/config.d.ts.map +0 -1
  460. package/script/analyzer/steps/003-risks/output.d.ts +0 -3
  461. package/script/analyzer/steps/003-risks/output.d.ts.map +0 -1
  462. package/script/analyzer/steps/003-risks/output.js +0 -19
  463. package/script/analyzer/treesiter/client.d.ts +0 -26
  464. package/script/analyzer/treesiter/client.d.ts.map +0 -1
  465. package/script/analyzer/treesiter/client.js +0 -165
@@ -0,0 +1,15 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ /**
5
+ * The character used to separate entries in the PATH environment variable.
6
+ */
7
+ export const DELIMITER = ":" as const;
8
+ /**
9
+ * The character used to separate components of a file path.
10
+ */
11
+ export const SEPARATOR = "/" as const;
12
+ /**
13
+ * A regular expression that matches one or more path separators.
14
+ */
15
+ export const SEPARATOR_PATTERN = /\/+/;
@@ -0,0 +1,72 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ import { assertArg } from "../_common/dirname.js";
5
+ import { stripTrailingSeparators } from "../_common/strip_trailing_separators.js";
6
+ import { isPosixPathSeparator } from "./_util.js";
7
+ import { fromFileUrl } from "./from_file_url.js";
8
+
9
+ /**
10
+ * Return the directory path of a `path`.
11
+ *
12
+ * @example Usage
13
+ * ```ts
14
+ * import { dirname } from "@std/path/posix/dirname";
15
+ * import { assertEquals } from "@std/assert";
16
+ *
17
+ * assertEquals(dirname("/home/user/Documents/"), "/home/user");
18
+ * assertEquals(dirname("/home/user/Documents/image.png"), "/home/user/Documents");
19
+ * assertEquals(dirname("https://deno.land/std/path/mod.ts"), "https://deno.land/std/path");
20
+ * assertEquals(dirname(new URL("file:///home/user/Documents/image.png")), "/home/user/Documents");
21
+ * ```
22
+ *
23
+ * @example Working with URLs
24
+ *
25
+ * ```ts
26
+ * import { dirname } from "@std/path/posix/dirname";
27
+ * import { assertEquals } from "@std/assert";
28
+ *
29
+ * assertEquals(dirname("https://deno.land/std/path/mod.ts"), "https://deno.land/std/path");
30
+ * assertEquals(dirname("https://deno.land/std/path/mod.ts?a=b"), "https://deno.land/std/path");
31
+ * assertEquals(dirname("https://deno.land/std/path/mod.ts#header"), "https://deno.land/std/path");
32
+ * ```
33
+ *
34
+ * @param path The path to get the directory from.
35
+ * @returns The directory path.
36
+ */
37
+ export function dirname(path: string | URL): string {
38
+ if (path instanceof URL) {
39
+ path = fromFileUrl(path);
40
+ }
41
+ assertArg(path);
42
+
43
+ let end = -1;
44
+ let matchedNonSeparator = false;
45
+
46
+ for (let i = path.length - 1; i >= 1; --i) {
47
+ if (isPosixPathSeparator(path.charCodeAt(i))) {
48
+ if (matchedNonSeparator) {
49
+ end = i;
50
+ break;
51
+ }
52
+ } else {
53
+ matchedNonSeparator = true;
54
+ }
55
+ }
56
+
57
+ // No matches. Fallback based on provided path:
58
+ //
59
+ // - leading slashes paths
60
+ // "/foo" => "/"
61
+ // "///foo" => "/"
62
+ // - no slash path
63
+ // "foo" => "."
64
+ if (end === -1) {
65
+ return isPosixPathSeparator(path.charCodeAt(0)) ? "/" : ".";
66
+ }
67
+
68
+ return stripTrailingSeparators(
69
+ path.slice(0, end),
70
+ isPosixPathSeparator,
71
+ );
72
+ }
@@ -0,0 +1,96 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ import { CHAR_DOT } from "../_common/constants.js";
5
+ import { assertPath } from "../_common/assert_path.js";
6
+ import { isPosixPathSeparator } from "./_util.js";
7
+ import { fromFileUrl } from "./from_file_url.js";
8
+
9
+ /**
10
+ * Return the extension of the `path` with leading period.
11
+ *
12
+ * @example Usage
13
+ * ```ts
14
+ * import { extname } from "@std/path/posix/extname";
15
+ * import { assertEquals } from "@std/assert";
16
+ *
17
+ * assertEquals(extname("/home/user/Documents/file.ts"), ".ts");
18
+ * assertEquals(extname("/home/user/Documents/"), "");
19
+ * assertEquals(extname("/home/user/Documents/image.png"), ".png");
20
+ * assertEquals(extname(new URL("file:///home/user/Documents/file.ts")), ".ts");
21
+ * assertEquals(extname(new URL("file:///home/user/Documents/file.ts?a=b")), ".ts");
22
+ * assertEquals(extname(new URL("file:///home/user/Documents/file.ts#header")), ".ts");
23
+ * ```
24
+ *
25
+ * @example Working with URLs
26
+ *
27
+ * Note: This function doesn't automatically strip hash and query parts from
28
+ * URLs. If your URL contains a hash or query, remove them before passing the
29
+ * URL to the function. This can be done by passing the URL to `new URL(url)`,
30
+ * and setting the `hash` and `search` properties to empty strings.
31
+ *
32
+ * ```ts
33
+ * import { extname } from "@std/path/posix/extname";
34
+ * import { assertEquals } from "@std/assert";
35
+ *
36
+ * assertEquals(extname("https://deno.land/std/path/mod.ts"), ".ts");
37
+ * assertEquals(extname("https://deno.land/std/path/mod.ts?a=b"), ".ts?a=b");
38
+ * assertEquals(extname("https://deno.land/std/path/mod.ts#header"), ".ts#header");
39
+ * ```
40
+ *
41
+ * @param path The path to get the extension from.
42
+ * @returns The extension (ex. for `file.ts` returns `.ts`).
43
+ */
44
+ export function extname(path: string | URL): string {
45
+ if (path instanceof URL) {
46
+ path = fromFileUrl(path);
47
+ }
48
+ assertPath(path);
49
+
50
+ let startDot = -1;
51
+ let startPart = 0;
52
+ let end = -1;
53
+ let matchedSlash = true;
54
+ // Track the state of characters (if any) we see before our first dot and
55
+ // after any path separator we find
56
+ let preDotState = 0;
57
+ for (let i = path.length - 1; i >= 0; --i) {
58
+ const code = path.charCodeAt(i);
59
+ if (isPosixPathSeparator(code)) {
60
+ // If we reached a path separator that was not part of a set of path
61
+ // separators at the end of the string, stop now
62
+ if (!matchedSlash) {
63
+ startPart = i + 1;
64
+ break;
65
+ }
66
+ continue;
67
+ }
68
+ if (end === -1) {
69
+ // We saw the first non-path separator, mark this as the end of our
70
+ // extension
71
+ matchedSlash = false;
72
+ end = i + 1;
73
+ }
74
+ if (code === CHAR_DOT) {
75
+ // If this is our first dot, mark it as the start of our extension
76
+ if (startDot === -1) startDot = i;
77
+ else if (preDotState !== 1) preDotState = 1;
78
+ } else if (startDot !== -1) {
79
+ // We saw a non-dot and non-path separator before our dot, so we should
80
+ // have a good chance at having a non-empty extension
81
+ preDotState = -1;
82
+ }
83
+ }
84
+
85
+ if (
86
+ startDot === -1 ||
87
+ end === -1 ||
88
+ // We saw a non-dot character immediately before the dot
89
+ preDotState === 0 ||
90
+ // The (right-most) trimmed path component is exactly '..'
91
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)
92
+ ) {
93
+ return "";
94
+ }
95
+ return path.slice(startDot, end);
96
+ }
@@ -0,0 +1,31 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ import { _format, assertArg } from "../_common/format.js";
5
+ import type { ParsedPath } from "../types.js";
6
+
7
+ /**
8
+ * Generate a path from `ParsedPath` object.
9
+ *
10
+ * @example Usage
11
+ * ```ts
12
+ * import { format } from "@std/path/posix/format";
13
+ * import { assertEquals } from "@std/assert";
14
+ *
15
+ * const path = format({
16
+ * root: "/",
17
+ * dir: "/path/dir",
18
+ * base: "file.txt",
19
+ * ext: ".txt",
20
+ * name: "file"
21
+ * });
22
+ * assertEquals(path, "/path/dir/file.txt");
23
+ * ```
24
+ *
25
+ * @param pathObject The path object to format.
26
+ * @returns The formatted path.
27
+ */
28
+ export function format(pathObject: Partial<ParsedPath>): string {
29
+ assertArg(pathObject);
30
+ return _format("/", pathObject);
31
+ }
@@ -0,0 +1,25 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ import { assertArg } from "../_common/from_file_url.js";
5
+
6
+ /**
7
+ * Converts a file URL to a path string.
8
+ *
9
+ * @example Usage
10
+ * ```ts
11
+ * import { fromFileUrl } from "@std/path/posix/from-file-url";
12
+ * import { assertEquals } from "@std/assert";
13
+ *
14
+ * assertEquals(fromFileUrl(new URL("file:///home/foo")), "/home/foo");
15
+ * ```
16
+ *
17
+ * @param url The file URL to convert.
18
+ * @returns The path string.
19
+ */
20
+ export function fromFileUrl(url: URL | string): string {
21
+ url = assertArg(url);
22
+ return decodeURIComponent(
23
+ url.pathname.replace(/%(?![0-9A-Fa-f]{2})/g, "%25"),
24
+ );
25
+ }
@@ -0,0 +1,94 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ import {
5
+ _globToRegExp,
6
+ type GlobConstants,
7
+ type GlobOptions,
8
+ } from "../_common/glob_to_reg_exp.js";
9
+
10
+ export type { GlobOptions };
11
+
12
+ const constants: GlobConstants = {
13
+ sep: "/+",
14
+ sepMaybe: "/*",
15
+ seps: ["/"],
16
+ globstar: "(?:[^/]*(?:/|$)+)*",
17
+ wildcard: "[^/]*",
18
+ escapePrefix: "\\",
19
+ };
20
+
21
+ /** Convert a glob string to a regular expression.
22
+ *
23
+ * Tries to match bash glob expansion as closely as possible.
24
+ *
25
+ * Basic glob syntax:
26
+ * - `*` - Matches everything without leaving the path segment.
27
+ * - `?` - Matches any single character.
28
+ * - `{foo,bar}` - Matches `foo` or `bar`.
29
+ * - `[abcd]` - Matches `a`, `b`, `c` or `d`.
30
+ * - `[a-d]` - Matches `a`, `b`, `c` or `d`.
31
+ * - `[!abcd]` - Matches any single character besides `a`, `b`, `c` or `d`.
32
+ * - `[[:<class>:]]` - Matches any character belonging to `<class>`.
33
+ * - `[[:alnum:]]` - Matches any digit or letter.
34
+ * - `[[:digit:]abc]` - Matches any digit, `a`, `b` or `c`.
35
+ * - See https://facelessuser.github.io/wcmatch/glob/#posix-character-classes
36
+ * for a complete list of supported character classes.
37
+ * - `\` - Escapes the next character for an `os` other than `"windows"`.
38
+ * - \` - Escapes the next character for `os` set to `"windows"`.
39
+ * - `/` - Path separator.
40
+ * - `\` - Additional path separator only for `os` set to `"windows"`.
41
+ *
42
+ * Extended syntax:
43
+ * - Requires `{ extended: true }`.
44
+ * - `?(foo|bar)` - Matches 0 or 1 instance of `{foo,bar}`.
45
+ * - `@(foo|bar)` - Matches 1 instance of `{foo,bar}`. They behave the same.
46
+ * - `*(foo|bar)` - Matches _n_ instances of `{foo,bar}`.
47
+ * - `+(foo|bar)` - Matches _n > 0_ instances of `{foo,bar}`.
48
+ * - `!(foo|bar)` - Matches anything other than `{foo,bar}`.
49
+ * - See https://www.linuxjournal.com/content/bash-extended-globbing.
50
+ *
51
+ * Globstar syntax:
52
+ * - Requires `{ globstar: true }`.
53
+ * - `**` - Matches any number of any path segments.
54
+ * - Must comprise its entire path segment in the provided glob.
55
+ * - See https://www.linuxjournal.com/content/globstar-new-bash-globbing-option.
56
+ *
57
+ * Note the following properties:
58
+ * - The generated `RegExp` is anchored at both start and end.
59
+ * - Repeating and trailing separators are tolerated. Trailing separators in the
60
+ * provided glob have no meaning and are discarded.
61
+ * - Absolute globs will only match absolute paths, etc.
62
+ * - Empty globs will match nothing.
63
+ * - Any special glob syntax must be contained to one path segment. For example,
64
+ * `?(foo|bar/baz)` is invalid. The separator will take precedence and the
65
+ * first segment ends with an unclosed group.
66
+ * - If a path segment ends with unclosed groups or a dangling escape prefix, a
67
+ * parse error has occurred. Every character for that segment is taken
68
+ * literally in this event.
69
+ *
70
+ * Limitations:
71
+ * - A negative group like `!(foo|bar)` will wrongly be converted to a negative
72
+ * look-ahead followed by a wildcard. This means that `!(foo).js` will wrongly
73
+ * fail to match `foobar.js`, even though `foobar` is not `foo`. Effectively,
74
+ * `!(foo|bar)` is treated like `!(@(foo|bar)*)`. This will work correctly if
75
+ * the group occurs not nested at the end of the segment.
76
+ *
77
+ * @example Usage
78
+ * ```ts
79
+ * import { globToRegExp } from "@std/path/posix/glob-to-regexp";
80
+ * import { assertEquals } from "@std/assert";
81
+ *
82
+ * assertEquals(globToRegExp("*.js"), /^[^/]*\.js\/*$/);
83
+ * ```
84
+ *
85
+ * @param glob Glob string to convert.
86
+ * @param options Conversion options.
87
+ * @returns The regular expression equivalent to the glob.
88
+ */
89
+ export function globToRegExp(
90
+ glob: string,
91
+ options: GlobOptions = {},
92
+ ): RegExp {
93
+ return _globToRegExp(constants, glob, options);
94
+ }
@@ -0,0 +1,25 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ import { assertPath } from "../_common/assert_path.js";
5
+ import { isPosixPathSeparator } from "./_util.js";
6
+
7
+ /**
8
+ * Verifies whether provided path is absolute.
9
+ *
10
+ * @example Usage
11
+ * ```ts
12
+ * import { isAbsolute } from "@std/path/posix/is-absolute";
13
+ * import { assert, assertFalse } from "@std/assert";
14
+ *
15
+ * assert(isAbsolute("/home/user/Documents/"));
16
+ * assertFalse(isAbsolute("home/user/Documents/"));
17
+ * ```
18
+ *
19
+ * @param path The path to verify.
20
+ * @returns Whether the path is absolute.
21
+ */
22
+ export function isAbsolute(path: string): boolean {
23
+ assertPath(path);
24
+ return path.length > 0 && isPosixPathSeparator(path.charCodeAt(0));
25
+ }
@@ -0,0 +1,46 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ import { assertPath } from "../_common/assert_path.js";
5
+ import { fromFileUrl } from "./from_file_url.js";
6
+ import { normalize } from "./normalize.js";
7
+
8
+ /**
9
+ * Join all given a sequence of `paths`,then normalizes the resulting path.
10
+ *
11
+ * @example Usage
12
+ * ```ts
13
+ * import { join } from "@std/path/posix/join";
14
+ * import { assertEquals } from "@std/assert";
15
+ *
16
+ * assertEquals(join("/foo", "bar", "baz/asdf", "quux", ".."), "/foo/bar/baz/asdf");
17
+ * assertEquals(join(new URL("file:///foo"), "bar", "baz/asdf", "quux", ".."), "/foo/bar/baz/asdf");
18
+ * ```
19
+ *
20
+ * @example Working with URLs
21
+ * ```ts
22
+ * import { join } from "@std/path/posix/join";
23
+ * import { assertEquals } from "@std/assert";
24
+ *
25
+ * const url = new URL("https://deno.land");
26
+ * url.pathname = join("std", "path", "mod.ts");
27
+ * assertEquals(url.href, "https://deno.land/std/path/mod.ts");
28
+ *
29
+ * url.pathname = join("//std", "path/", "/mod.ts");
30
+ * assertEquals(url.href, "https://deno.land/std/path/mod.ts");
31
+ * ```
32
+ *
33
+ * @param path The path to join. This can be string or file URL.
34
+ * @param paths The paths to join.
35
+ * @returns The joined path.
36
+ */
37
+ export function join(path?: URL | string, ...paths: string[]): string {
38
+ if (path === undefined) return ".";
39
+ if (path instanceof URL) {
40
+ path = fromFileUrl(path);
41
+ }
42
+ paths = path ? [path, ...paths] : paths;
43
+ paths.forEach((path) => assertPath(path));
44
+ const joined = paths.filter((path) => path.length > 0).join("/");
45
+ return joined === "" ? "." : normalize(joined);
46
+ }
@@ -0,0 +1,45 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ import type { GlobOptions } from "../_common/glob_to_reg_exp.js";
5
+ import { join } from "./join.js";
6
+ import { SEPARATOR } from "./constants.js";
7
+ import { normalizeGlob } from "./normalize_glob.js";
8
+
9
+ export type { GlobOptions };
10
+
11
+ /**
12
+ * Like join(), but doesn't collapse "**\/.." when `globstar` is true.
13
+ *
14
+ * @example Usage
15
+ * ```ts
16
+ * import { joinGlobs } from "@std/path/posix/join-globs";
17
+ * import { assertEquals } from "@std/assert";
18
+ *
19
+ * const path = joinGlobs(["foo", "bar", "**"], { globstar: true });
20
+ * assertEquals(path, "foo/bar/**");
21
+ * ```
22
+ *
23
+ * @param globs The globs to join.
24
+ * @param options The options to use.
25
+ * @returns The joined path.
26
+ */
27
+ export function joinGlobs(
28
+ globs: string[],
29
+ options: Pick<GlobOptions, "globstar"> = {},
30
+ ): string {
31
+ const { globstar = false } = options;
32
+ if (!globstar || globs.length === 0) {
33
+ return join(...globs);
34
+ }
35
+ let joined: string | undefined;
36
+ for (const glob of globs) {
37
+ const path = glob;
38
+ if (path.length > 0) {
39
+ if (!joined) joined = path;
40
+ else joined += `${SEPARATOR}${path}`;
41
+ }
42
+ }
43
+ if (!joined) return ".";
44
+ return normalizeGlob(joined, { globstar });
45
+ }
@@ -0,0 +1,63 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ import { assertArg } from "../_common/normalize.js";
5
+ import { normalizeString } from "../_common/normalize_string.js";
6
+ import { isPosixPathSeparator } from "./_util.js";
7
+ import { fromFileUrl } from "./from_file_url.js";
8
+
9
+ /**
10
+ * Normalize the `path`, resolving `'..'` and `'.'` segments.
11
+ * Note that resolving these segments does not necessarily mean that all will be eliminated.
12
+ * A `'..'` at the top-level will be preserved, and an empty path is canonically `'.'`.
13
+ *
14
+ * @example Usage
15
+ * ```ts
16
+ * import { normalize } from "@std/path/posix/normalize";
17
+ * import { assertEquals } from "@std/assert";
18
+ *
19
+ * assertEquals(normalize("/foo/bar//baz/asdf/quux/.."), "/foo/bar/baz/asdf");
20
+ * assertEquals(normalize(new URL("file:///foo/bar//baz/asdf/quux/..")), "/foo/bar/baz/asdf/");
21
+ * ```
22
+ *
23
+ * @example Working with URLs
24
+ *
25
+ * Note: This function will remove the double slashes from a URL's scheme.
26
+ * Hence, do not pass a full URL to this function. Instead, pass the pathname of
27
+ * the URL.
28
+ *
29
+ * ```ts
30
+ * import { normalize } from "@std/path/posix/normalize";
31
+ * import { assertEquals } from "@std/assert";
32
+ *
33
+ * const url = new URL("https://deno.land");
34
+ * url.pathname = normalize("//std//assert//.//mod.ts");
35
+ * assertEquals(url.href, "https://deno.land/std/assert/mod.ts");
36
+ *
37
+ * url.pathname = normalize("std/assert/../async/retry.ts");
38
+ * assertEquals(url.href, "https://deno.land/std/async/retry.ts");
39
+ * ```
40
+ *
41
+ * @param path The path to normalize.
42
+ * @returns The normalized path.
43
+ */
44
+ export function normalize(path: string | URL): string {
45
+ if (path instanceof URL) {
46
+ path = fromFileUrl(path);
47
+ }
48
+ assertArg(path);
49
+
50
+ const isAbsolute = isPosixPathSeparator(path.charCodeAt(0));
51
+ const trailingSeparator = isPosixPathSeparator(
52
+ path.charCodeAt(path.length - 1),
53
+ );
54
+
55
+ // Normalize the path
56
+ path = normalizeString(path, !isAbsolute, "/", isPosixPathSeparator);
57
+
58
+ if (path.length === 0 && !isAbsolute) path = ".";
59
+ if (path.length > 0 && trailingSeparator) path += "/";
60
+
61
+ if (isAbsolute) return `/${path}`;
62
+ return path;
63
+ }
@@ -0,0 +1,43 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ import type { GlobOptions } from "../_common/glob_to_reg_exp.js";
5
+ import { normalize } from "./normalize.js";
6
+ import { SEPARATOR_PATTERN } from "./constants.js";
7
+
8
+ export type { GlobOptions };
9
+
10
+ /**
11
+ * Like normalize(), but doesn't collapse "**\/.." when `globstar` is true.
12
+ *
13
+ * @example Usage
14
+ * ```ts
15
+ * import { normalizeGlob } from "@std/path/posix/normalize-glob";
16
+ * import { assertEquals } from "@std/assert";
17
+ *
18
+ * const path = normalizeGlob("foo/bar/../*", { globstar: true });
19
+ * assertEquals(path, "foo/*");
20
+ * ```
21
+ *
22
+ * @param glob The glob to normalize.
23
+ * @param options The options to use.
24
+ * @returns The normalized path.
25
+ */
26
+ export function normalizeGlob(
27
+ glob: string,
28
+ options: Pick<GlobOptions, "globstar"> = {},
29
+ ): string {
30
+ const { globstar = false }: GlobOptions = options;
31
+ if (glob.match(/\0/g)) {
32
+ throw new Error(`Glob contains invalid characters: "${glob}"`);
33
+ }
34
+ if (!globstar) {
35
+ return normalize(glob);
36
+ }
37
+ const s = SEPARATOR_PATTERN.source;
38
+ const badParentPattern = new RegExp(
39
+ `(?<=(${s}|^)\\*\\*${s})\\.\\.(?=${s}|$)`,
40
+ "g",
41
+ );
42
+ return normalize(glob.replace(badParentPattern, "\0")).replace(/\0/g, "..");
43
+ }
@@ -0,0 +1,121 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ import { CHAR_DOT } from "../_common/constants.js";
5
+ import type { ParsedPath } from "../types.js";
6
+ import { stripTrailingSeparators } from "../_common/strip_trailing_separators.js";
7
+ import { assertPath } from "../_common/assert_path.js";
8
+ import { isPosixPathSeparator } from "./_util.js";
9
+
10
+ export type { ParsedPath } from "../types.js";
11
+
12
+ /**
13
+ * Return a `ParsedPath` object of the `path`.
14
+ *
15
+ * @example Usage
16
+ * ```ts
17
+ * import { parse } from "@std/path/posix/parse";
18
+ * import { assertEquals } from "@std/assert";
19
+ *
20
+ * const path = parse("/home/user/file.txt");
21
+ * assertEquals(path, {
22
+ * root: "/",
23
+ * dir: "/home/user",
24
+ * base: "file.txt",
25
+ * ext: ".txt",
26
+ * name: "file"
27
+ * });
28
+ * ```
29
+ *
30
+ * @param path The path to parse.
31
+ * @returns The parsed path object.
32
+ */
33
+ export function parse(path: string): ParsedPath {
34
+ assertPath(path);
35
+
36
+ const ret: ParsedPath = { root: "", dir: "", base: "", ext: "", name: "" };
37
+ if (path.length === 0) return ret;
38
+ const isAbsolute = isPosixPathSeparator(path.charCodeAt(0));
39
+ let start: number;
40
+ if (isAbsolute) {
41
+ ret.root = "/";
42
+ start = 1;
43
+ } else {
44
+ start = 0;
45
+ }
46
+ let startDot = -1;
47
+ let startPart = 0;
48
+ let end = -1;
49
+ let matchedSlash = true;
50
+ let i = path.length - 1;
51
+
52
+ // Track the state of characters (if any) we see before our first dot and
53
+ // after any path separator we find
54
+ let preDotState = 0;
55
+
56
+ // Get non-dir info
57
+ for (; i >= start; --i) {
58
+ const code = path.charCodeAt(i);
59
+ if (isPosixPathSeparator(code)) {
60
+ // If we reached a path separator that was not part of a set of path
61
+ // separators at the end of the string, stop now
62
+ if (!matchedSlash) {
63
+ startPart = i + 1;
64
+ break;
65
+ }
66
+ continue;
67
+ }
68
+ if (end === -1) {
69
+ // We saw the first non-path separator, mark this as the end of our
70
+ // extension
71
+ matchedSlash = false;
72
+ end = i + 1;
73
+ }
74
+ if (code === CHAR_DOT) {
75
+ // If this is our first dot, mark it as the start of our extension
76
+ if (startDot === -1) startDot = i;
77
+ else if (preDotState !== 1) preDotState = 1;
78
+ } else if (startDot !== -1) {
79
+ // We saw a non-dot and non-path separator before our dot, so we should
80
+ // have a good chance at having a non-empty extension
81
+ preDotState = -1;
82
+ }
83
+ }
84
+
85
+ if (
86
+ startDot === -1 ||
87
+ end === -1 ||
88
+ // We saw a non-dot character immediately before the dot
89
+ preDotState === 0 ||
90
+ // The (right-most) trimmed path component is exactly '..'
91
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)
92
+ ) {
93
+ if (end !== -1) {
94
+ if (startPart === 0 && isAbsolute) {
95
+ ret.base = ret.name = path.slice(1, end);
96
+ } else {
97
+ ret.base = ret.name = path.slice(startPart, end);
98
+ }
99
+ }
100
+ // Fallback to '/' in case there is no basename
101
+ ret.base = ret.base || "/";
102
+ } else {
103
+ if (startPart === 0 && isAbsolute) {
104
+ ret.name = path.slice(1, startDot);
105
+ ret.base = path.slice(1, end);
106
+ } else {
107
+ ret.name = path.slice(startPart, startDot);
108
+ ret.base = path.slice(startPart, end);
109
+ }
110
+ ret.ext = path.slice(startDot, end);
111
+ }
112
+
113
+ if (startPart > 0) {
114
+ ret.dir = stripTrailingSeparators(
115
+ path.slice(0, startPart - 1),
116
+ isPosixPathSeparator,
117
+ );
118
+ } else if (isAbsolute) ret.dir = "/";
119
+
120
+ return ret;
121
+ }