@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,184 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ import { CHAR_COLON, CHAR_DOT } from "../_common/constants.js";
5
+ import type { ParsedPath } from "../types.js";
6
+ import { assertPath } from "../_common/assert_path.js";
7
+ import { isPathSeparator, isWindowsDeviceRoot } from "./_util.js";
8
+
9
+ export type { ParsedPath } from "../types.js";
10
+
11
+ /**
12
+ * Return a `ParsedPath` object of the `path`.
13
+ *
14
+ * @example Usage
15
+ * ```ts
16
+ * import { parse } from "@std/path/windows/parse";
17
+ * import { assertEquals } from "@std/assert";
18
+ *
19
+ * const parsed = parse("C:\\foo\\bar\\baz.ext");
20
+ * assertEquals(parsed, {
21
+ * root: "C:\\",
22
+ * dir: "C:\\foo\\bar",
23
+ * base: "baz.ext",
24
+ * ext: ".ext",
25
+ * name: "baz",
26
+ * });
27
+ * ```
28
+ *
29
+ * @param path The path to parse.
30
+ * @returns The `ParsedPath` object.
31
+ */
32
+ export function parse(path: string): ParsedPath {
33
+ assertPath(path);
34
+
35
+ const ret: ParsedPath = { root: "", dir: "", base: "", ext: "", name: "" };
36
+
37
+ const len = path.length;
38
+ if (len === 0) return ret;
39
+
40
+ let rootEnd = 0;
41
+ let code = path.charCodeAt(0);
42
+
43
+ // Try to match a root
44
+ if (len > 1) {
45
+ if (isPathSeparator(code)) {
46
+ // Possible UNC root
47
+
48
+ rootEnd = 1;
49
+ if (isPathSeparator(path.charCodeAt(1))) {
50
+ // Matched double path separator at beginning
51
+ let j = 2;
52
+ let last = j;
53
+ // Match 1 or more non-path separators
54
+ for (; j < len; ++j) {
55
+ if (isPathSeparator(path.charCodeAt(j))) break;
56
+ }
57
+ if (j < len && j !== last) {
58
+ // Matched!
59
+ last = j;
60
+ // Match 1 or more path separators
61
+ for (; j < len; ++j) {
62
+ if (!isPathSeparator(path.charCodeAt(j))) break;
63
+ }
64
+ if (j < len && j !== last) {
65
+ // Matched!
66
+ last = j;
67
+ // Match 1 or more non-path separators
68
+ for (; j < len; ++j) {
69
+ if (isPathSeparator(path.charCodeAt(j))) break;
70
+ }
71
+ if (j === len) {
72
+ // We matched a UNC root only
73
+
74
+ rootEnd = j;
75
+ } else if (j !== last) {
76
+ // We matched a UNC root with leftovers
77
+
78
+ rootEnd = j + 1;
79
+ }
80
+ }
81
+ }
82
+ }
83
+ } else if (isWindowsDeviceRoot(code)) {
84
+ // Possible device root
85
+
86
+ if (path.charCodeAt(1) === CHAR_COLON) {
87
+ rootEnd = 2;
88
+ if (len > 2) {
89
+ if (isPathSeparator(path.charCodeAt(2))) {
90
+ if (len === 3) {
91
+ // `path` contains just a drive root, exit early to avoid
92
+ // unnecessary work
93
+ ret.root = ret.dir = path;
94
+ ret.base = "\\";
95
+ return ret;
96
+ }
97
+ rootEnd = 3;
98
+ }
99
+ } else {
100
+ // `path` contains just a relative drive root, exit early to avoid
101
+ // unnecessary work
102
+ ret.root = ret.dir = path;
103
+ return ret;
104
+ }
105
+ }
106
+ }
107
+ } else if (isPathSeparator(code)) {
108
+ // `path` contains just a path separator, exit early to avoid
109
+ // unnecessary work
110
+ ret.root = ret.dir = path;
111
+ ret.base = "\\";
112
+ return ret;
113
+ }
114
+
115
+ if (rootEnd > 0) ret.root = path.slice(0, rootEnd);
116
+
117
+ let startDot = -1;
118
+ let startPart = rootEnd;
119
+ let end = -1;
120
+ let matchedSlash = true;
121
+ let i = path.length - 1;
122
+
123
+ // Track the state of characters (if any) we see before our first dot and
124
+ // after any path separator we find
125
+ let preDotState = 0;
126
+
127
+ // Get non-dir info
128
+ for (; i >= rootEnd; --i) {
129
+ code = path.charCodeAt(i);
130
+ if (isPathSeparator(code)) {
131
+ // If we reached a path separator that was not part of a set of path
132
+ // separators at the end of the string, stop now
133
+ if (!matchedSlash) {
134
+ startPart = i + 1;
135
+ break;
136
+ }
137
+ continue;
138
+ }
139
+ if (end === -1) {
140
+ // We saw the first non-path separator, mark this as the end of our
141
+ // extension
142
+ matchedSlash = false;
143
+ end = i + 1;
144
+ }
145
+ if (code === CHAR_DOT) {
146
+ // If this is our first dot, mark it as the start of our extension
147
+ if (startDot === -1) startDot = i;
148
+ else if (preDotState !== 1) preDotState = 1;
149
+ } else if (startDot !== -1) {
150
+ // We saw a non-dot and non-path separator before our dot, so we should
151
+ // have a good chance at having a non-empty extension
152
+ preDotState = -1;
153
+ }
154
+ }
155
+
156
+ if (
157
+ startDot === -1 ||
158
+ end === -1 ||
159
+ // We saw a non-dot character immediately before the dot
160
+ preDotState === 0 ||
161
+ // The (right-most) trimmed path component is exactly '..'
162
+ (preDotState === 1 && startDot === end - 1 && startDot === startPart + 1)
163
+ ) {
164
+ if (end !== -1) {
165
+ ret.base = ret.name = path.slice(startPart, end);
166
+ }
167
+ } else {
168
+ ret.name = path.slice(startPart, startDot);
169
+ ret.base = path.slice(startPart, end);
170
+ ret.ext = path.slice(startDot, end);
171
+ }
172
+
173
+ // Fallback to '\' in case there is no basename
174
+ ret.base = ret.base || "\\";
175
+
176
+ // If the directory is the root, use the entire root as the `dir` including
177
+ // the trailing slash if any (`C:\abc` -> `C:\`). Otherwise, strip out the
178
+ // trailing slash (`C:\abc\def` -> `C:\abc`).
179
+ if (startPart > 0 && startPart !== rootEnd) {
180
+ ret.dir = path.slice(0, startPart - 1);
181
+ } else ret.dir = ret.root;
182
+
183
+ return ret;
184
+ }
@@ -0,0 +1,128 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ import { CHAR_BACKWARD_SLASH } from "../_common/constants.js";
5
+ import { resolve } from "./resolve.js";
6
+ import { assertArgs } from "../_common/relative.js";
7
+
8
+ /**
9
+ * Return the relative path from `from` to `to` based on current working directory.
10
+ *
11
+ * An example in windows, for instance:
12
+ * from = 'C:\\orandea\\test\\aaa'
13
+ * to = 'C:\\orandea\\impl\\bbb'
14
+ * The output of the function should be: '..\\..\\impl\\bbb'
15
+ *
16
+ * @example Usage
17
+ * ```ts
18
+ * import { relative } from "@std/path/windows/relative";
19
+ * import { assertEquals } from "@std/assert";
20
+ *
21
+ * const relativePath = relative("C:\\foobar\\test\\aaa", "C:\\foobar\\impl\\bbb");
22
+ * assertEquals(relativePath, "..\\..\\impl\\bbb");
23
+ * ```
24
+ *
25
+ * @param from The path from which to calculate the relative path
26
+ * @param to The path to which to calculate the relative path
27
+ * @returns The relative path from `from` to `to`
28
+ */
29
+ export function relative(from: string, to: string): string {
30
+ assertArgs(from, to);
31
+
32
+ const fromOrig = resolve(from);
33
+ const toOrig = resolve(to);
34
+
35
+ if (fromOrig === toOrig) return "";
36
+
37
+ from = fromOrig.toLowerCase();
38
+ to = toOrig.toLowerCase();
39
+
40
+ if (from === to) return "";
41
+
42
+ // Trim any leading backslashes
43
+ let fromStart = 0;
44
+ let fromEnd = from.length;
45
+ for (; fromStart < fromEnd; ++fromStart) {
46
+ if (from.charCodeAt(fromStart) !== CHAR_BACKWARD_SLASH) break;
47
+ }
48
+ // Trim trailing backslashes (applicable to UNC paths only)
49
+ for (; fromEnd - 1 > fromStart; --fromEnd) {
50
+ if (from.charCodeAt(fromEnd - 1) !== CHAR_BACKWARD_SLASH) break;
51
+ }
52
+ const fromLen = fromEnd - fromStart;
53
+
54
+ // Trim any leading backslashes
55
+ let toStart = 0;
56
+ let toEnd = to.length;
57
+ for (; toStart < toEnd; ++toStart) {
58
+ if (to.charCodeAt(toStart) !== CHAR_BACKWARD_SLASH) break;
59
+ }
60
+ // Trim trailing backslashes (applicable to UNC paths only)
61
+ for (; toEnd - 1 > toStart; --toEnd) {
62
+ if (to.charCodeAt(toEnd - 1) !== CHAR_BACKWARD_SLASH) break;
63
+ }
64
+ const toLen = toEnd - toStart;
65
+
66
+ // Compare paths to find the longest common path from root
67
+ const length = fromLen < toLen ? fromLen : toLen;
68
+ let lastCommonSep = -1;
69
+ let i = 0;
70
+ for (; i <= length; ++i) {
71
+ if (i === length) {
72
+ if (toLen > length) {
73
+ if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
74
+ // We get here if `from` is the exact base path for `to`.
75
+ // For example: from='C:\\foo\\bar'; to='C:\\foo\\bar\\baz'
76
+ return toOrig.slice(toStart + i + 1);
77
+ } else if (i === 2) {
78
+ // We get here if `from` is the device root.
79
+ // For example: from='C:\\'; to='C:\\foo'
80
+ return toOrig.slice(toStart + i);
81
+ }
82
+ }
83
+ if (fromLen > length) {
84
+ if (from.charCodeAt(fromStart + i) === CHAR_BACKWARD_SLASH) {
85
+ // We get here if `to` is the exact base path for `from`.
86
+ // For example: from='C:\\foo\\bar'; to='C:\\foo'
87
+ lastCommonSep = i;
88
+ } else if (i === 2) {
89
+ // We get here if `to` is the device root.
90
+ // For example: from='C:\\foo\\bar'; to='C:\\'
91
+ lastCommonSep = 3;
92
+ }
93
+ }
94
+ break;
95
+ }
96
+ const fromCode = from.charCodeAt(fromStart + i);
97
+ const toCode = to.charCodeAt(toStart + i);
98
+ if (fromCode !== toCode) break;
99
+ else if (fromCode === CHAR_BACKWARD_SLASH) lastCommonSep = i;
100
+ }
101
+
102
+ // We found a mismatch before the first common path separator was seen, so
103
+ // return the original `to`.
104
+ if (i !== length && lastCommonSep === -1) {
105
+ return toOrig;
106
+ }
107
+
108
+ let out = "";
109
+ if (lastCommonSep === -1) lastCommonSep = 0;
110
+ // Generate the relative path based on the path difference between `to` and
111
+ // `from`
112
+ for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
113
+ if (i === fromEnd || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
114
+ if (out.length === 0) out += "..";
115
+ else out += "\\..";
116
+ }
117
+ }
118
+
119
+ // Lastly, append the rest of the destination (`to`) path that comes after
120
+ // the common path parts
121
+ if (out.length > 0) {
122
+ return out + toOrig.slice(toStart + lastCommonSep, toEnd);
123
+ } else {
124
+ toStart += lastCommonSep;
125
+ if (toOrig.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) ++toStart;
126
+ return toOrig.slice(toStart, toEnd);
127
+ }
128
+ }
@@ -0,0 +1,178 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+ import * as dntShim from "../../../../../../_dnt.shims.js";
4
+
5
+
6
+ import { CHAR_COLON } from "../_common/constants.js";
7
+ import { normalizeString } from "../_common/normalize_string.js";
8
+ import { assertPath } from "../_common/assert_path.js";
9
+ import { isPathSeparator, isWindowsDeviceRoot } from "./_util.js";
10
+
11
+ /**
12
+ * Resolves path segments into a `path`.
13
+ *
14
+ * @example Usage
15
+ * ```ts
16
+ * import { resolve } from "@std/path/windows/resolve";
17
+ * import { assertEquals } from "@std/assert";
18
+ *
19
+ * const resolved = resolve("C:\\foo\\bar", "..\\baz");
20
+ * assertEquals(resolved, "C:\\foo\\baz");
21
+ * ```
22
+ *
23
+ * @param pathSegments The path segments to process to path
24
+ * @returns The resolved path
25
+ */
26
+ export function resolve(...pathSegments: string[]): string {
27
+ let resolvedDevice = "";
28
+ let resolvedTail = "";
29
+ let resolvedAbsolute = false;
30
+
31
+ for (let i = pathSegments.length - 1; i >= -1; i--) {
32
+ let path: string;
33
+ // deno-lint-ignore no-explicit-any
34
+ const { Deno } = dntShim.dntGlobalThis as any;
35
+ if (i >= 0) {
36
+ path = pathSegments[i]!;
37
+ } else if (!resolvedDevice) {
38
+ if (typeof Deno?.cwd !== "function") {
39
+ throw new TypeError(
40
+ "Resolved a drive-letter-less path without a current working directory (CWD)",
41
+ );
42
+ }
43
+ path = Deno.cwd();
44
+ } else {
45
+ if (
46
+ typeof Deno?.env?.get !== "function" || typeof Deno?.cwd !== "function"
47
+ ) {
48
+ throw new TypeError(
49
+ "Resolved a relative path without a current working directory (CWD)",
50
+ );
51
+ }
52
+ path = Deno.cwd();
53
+
54
+ // Verify that a cwd was found and that it actually points
55
+ // to our drive. If not, default to the drive's root.
56
+ if (
57
+ path === undefined ||
58
+ path.slice(0, 3).toLowerCase() !== `${resolvedDevice.toLowerCase()}\\`
59
+ ) {
60
+ path = `${resolvedDevice}\\`;
61
+ }
62
+ }
63
+
64
+ assertPath(path);
65
+
66
+ const len = path.length;
67
+
68
+ // Skip empty entries
69
+ if (len === 0) continue;
70
+
71
+ let rootEnd = 0;
72
+ let device = "";
73
+ let isAbsolute = false;
74
+ const code = path.charCodeAt(0);
75
+
76
+ // Try to match a root
77
+ if (len > 1) {
78
+ if (isPathSeparator(code)) {
79
+ // Possible UNC root
80
+
81
+ // If we started with a separator, we know we at least have an
82
+ // absolute path of some kind (UNC or otherwise)
83
+ isAbsolute = true;
84
+
85
+ if (isPathSeparator(path.charCodeAt(1))) {
86
+ // Matched double path separator at beginning
87
+ let j = 2;
88
+ let last = j;
89
+ // Match 1 or more non-path separators
90
+ for (; j < len; ++j) {
91
+ if (isPathSeparator(path.charCodeAt(j))) break;
92
+ }
93
+ if (j < len && j !== last) {
94
+ const firstPart = path.slice(last, j);
95
+ // Matched!
96
+ last = j;
97
+ // Match 1 or more path separators
98
+ for (; j < len; ++j) {
99
+ if (!isPathSeparator(path.charCodeAt(j))) break;
100
+ }
101
+ if (j < len && j !== last) {
102
+ // Matched!
103
+ last = j;
104
+ // Match 1 or more non-path separators
105
+ for (; j < len; ++j) {
106
+ if (isPathSeparator(path.charCodeAt(j))) break;
107
+ }
108
+ if (j === len) {
109
+ // We matched a UNC root only
110
+ device = `\\\\${firstPart}\\${path.slice(last)}`;
111
+ rootEnd = j;
112
+ } else if (j !== last) {
113
+ // We matched a UNC root with leftovers
114
+
115
+ device = `\\\\${firstPart}\\${path.slice(last, j)}`;
116
+ rootEnd = j;
117
+ }
118
+ }
119
+ }
120
+ } else {
121
+ rootEnd = 1;
122
+ }
123
+ } else if (isWindowsDeviceRoot(code)) {
124
+ // Possible device root
125
+
126
+ if (path.charCodeAt(1) === CHAR_COLON) {
127
+ device = path.slice(0, 2);
128
+ rootEnd = 2;
129
+ if (len > 2) {
130
+ if (isPathSeparator(path.charCodeAt(2))) {
131
+ // Treat separator following drive name as an absolute path
132
+ // indicator
133
+ isAbsolute = true;
134
+ rootEnd = 3;
135
+ }
136
+ }
137
+ }
138
+ }
139
+ } else if (isPathSeparator(code)) {
140
+ // `path` contains just a path separator
141
+ rootEnd = 1;
142
+ isAbsolute = true;
143
+ }
144
+
145
+ if (
146
+ device.length > 0 &&
147
+ resolvedDevice.length > 0 &&
148
+ device.toLowerCase() !== resolvedDevice.toLowerCase()
149
+ ) {
150
+ // This path points to another device so it is not applicable
151
+ continue;
152
+ }
153
+
154
+ if (resolvedDevice.length === 0 && device.length > 0) {
155
+ resolvedDevice = device;
156
+ }
157
+ if (!resolvedAbsolute) {
158
+ resolvedTail = `${path.slice(rootEnd)}\\${resolvedTail}`;
159
+ resolvedAbsolute = isAbsolute;
160
+ }
161
+
162
+ if (resolvedAbsolute && resolvedDevice.length > 0) break;
163
+ }
164
+
165
+ // At this point the path should be resolved to a full absolute path,
166
+ // but handle relative paths to be safe (might happen when Deno.cwd()
167
+ // fails)
168
+
169
+ // Normalize the tail path
170
+ resolvedTail = normalizeString(
171
+ resolvedTail,
172
+ !resolvedAbsolute,
173
+ "\\",
174
+ isPathSeparator,
175
+ );
176
+
177
+ return resolvedDevice + (resolvedAbsolute ? "\\" : "") + resolvedTail || ".";
178
+ }
@@ -0,0 +1,38 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ import { encodeWhitespace } from "../_common/to_file_url.js";
5
+ import { isAbsolute } from "./is_absolute.js";
6
+
7
+ /**
8
+ * Converts a path string to a file URL.
9
+ *
10
+ * @example Usage
11
+ * ```ts
12
+ * import { toFileUrl } from "@std/path/windows/to-file-url";
13
+ * import { assertEquals } from "@std/assert";
14
+ *
15
+ * assertEquals(toFileUrl("\\home\\foo"), new URL("file:///home/foo"));
16
+ * assertEquals(toFileUrl("C:\\Users\\foo"), new URL("file:///C:/Users/foo"));
17
+ * assertEquals(toFileUrl("\\\\127.0.0.1\\home\\foo"), new URL("file://127.0.0.1/home/foo"));
18
+ * ```
19
+ * @param path The path to convert.
20
+ * @returns The file URL.
21
+ */
22
+ export function toFileUrl(path: string): URL {
23
+ if (!isAbsolute(path)) {
24
+ throw new TypeError(`Path must be absolute: received "${path}"`);
25
+ }
26
+ const [, hostname, pathname] = path.match(
27
+ /^(?:[/\\]{2}([^/\\]+)(?=[/\\](?:[^/\\]|$)))?(.*)/,
28
+ )!;
29
+ const url = new URL("file:///");
30
+ url.pathname = encodeWhitespace(pathname!.replace(/%/g, "%25"));
31
+ if (hostname !== undefined && hostname !== "localhost") {
32
+ url.hostname = hostname;
33
+ if (!url.hostname) {
34
+ throw new TypeError(`Invalid hostname: "${url.hostname}"`);
35
+ }
36
+ }
37
+ return url;
38
+ }
@@ -0,0 +1,60 @@
1
+ // Copyright 2018-2025 the Deno authors. MIT license.
2
+ // This module is browser compatible.
3
+
4
+ import {
5
+ CHAR_BACKWARD_SLASH,
6
+ CHAR_COLON,
7
+ CHAR_DOT,
8
+ CHAR_QUESTION_MARK,
9
+ } from "../_common/constants.js";
10
+ import { isWindowsDeviceRoot } from "./_util.js";
11
+ import { resolve } from "./resolve.js";
12
+
13
+ /**
14
+ * Resolves path to a namespace path
15
+ *
16
+ * @example Usage
17
+ * ```ts
18
+ * import { toNamespacedPath } from "@std/path/windows/to-namespaced-path";
19
+ * import { assertEquals } from "@std/assert";
20
+ *
21
+ * const namespaced = toNamespacedPath("C:\\foo\\bar");
22
+ * assertEquals(namespaced, "\\\\?\\C:\\foo\\bar");
23
+ * ```
24
+ *
25
+ * @param path The path to resolve to namespaced path
26
+ * @returns The resolved namespaced path
27
+ */
28
+ export function toNamespacedPath(path: string): string {
29
+ // Note: this will *probably* throw somewhere.
30
+ if (typeof path !== "string") return path;
31
+ if (path.length === 0) return "";
32
+
33
+ const resolvedPath = resolve(path);
34
+
35
+ if (resolvedPath.length >= 3) {
36
+ if (resolvedPath.charCodeAt(0) === CHAR_BACKWARD_SLASH) {
37
+ // Possible UNC root
38
+
39
+ if (resolvedPath.charCodeAt(1) === CHAR_BACKWARD_SLASH) {
40
+ const code = resolvedPath.charCodeAt(2);
41
+ if (code !== CHAR_QUESTION_MARK && code !== CHAR_DOT) {
42
+ // Matched non-long UNC root, convert the path to a long UNC path
43
+ return `\\\\?\\UNC\\${resolvedPath.slice(2)}`;
44
+ }
45
+ }
46
+ } else if (isWindowsDeviceRoot(resolvedPath.charCodeAt(0))) {
47
+ // Possible device root
48
+
49
+ if (
50
+ resolvedPath.charCodeAt(1) === CHAR_COLON &&
51
+ resolvedPath.charCodeAt(2) === CHAR_BACKWARD_SLASH
52
+ ) {
53
+ // Matched device root, convert the path to a long UNC path
54
+ return `\\\\?\\${resolvedPath}`;
55
+ }
56
+ }
57
+ }
58
+
59
+ return path;
60
+ }
@@ -0,0 +1,55 @@
1
+ // Ported from js-yaml v3.13.1:
2
+ // https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
3
+ // Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
4
+ // Copyright 2018-2026 the Deno authors. MIT license.
5
+
6
+ export const BOM = 0xfeff; /* BOM */
7
+ export const TAB = 0x09; /* Tab */
8
+ export const LINE_FEED = 0x0a; /* LF */
9
+ export const CARRIAGE_RETURN = 0x0d; /* CR */
10
+ export const SPACE = 0x20; /* Space */
11
+ export const EXCLAMATION = 0x21; /* ! */
12
+ export const DOUBLE_QUOTE = 0x22; /* " */
13
+ export const SHARP = 0x23; /* # */
14
+ export const PERCENT = 0x25; /* % */
15
+ export const AMPERSAND = 0x26; /* & */
16
+ export const SINGLE_QUOTE = 0x27; /* ' */
17
+ export const ASTERISK = 0x2a; /* * */
18
+ export const PLUS = 0x2b; /* + */
19
+ export const COMMA = 0x2c; /* , */
20
+ export const MINUS = 0x2d; /* - */
21
+ export const DOT = 0x2e; /* . */
22
+ export const COLON = 0x3a; /* : */
23
+ export const SMALLER_THAN = 0x3c; /* < */
24
+ export const GREATER_THAN = 0x3e; /* > */
25
+ export const QUESTION = 0x3f; /* ? */
26
+ export const COMMERCIAL_AT = 0x40; /* @ */
27
+ export const LEFT_SQUARE_BRACKET = 0x5b; /* [ */
28
+ export const BACKSLASH = 0x5c; /* \ */
29
+ export const RIGHT_SQUARE_BRACKET = 0x5d; /* ] */
30
+ export const GRAVE_ACCENT = 0x60; /* ` */
31
+ export const LEFT_CURLY_BRACKET = 0x7b; /* { */
32
+ export const VERTICAL_LINE = 0x7c; /* | */
33
+ export const RIGHT_CURLY_BRACKET = 0x7d; /* } */
34
+
35
+ export function isEOL(c: number): boolean {
36
+ return c === LINE_FEED || c === CARRIAGE_RETURN;
37
+ }
38
+
39
+ export function isWhiteSpace(c: number): boolean {
40
+ return c === TAB || c === SPACE;
41
+ }
42
+
43
+ export function isWhiteSpaceOrEOL(c: number): boolean {
44
+ return isWhiteSpace(c) || isEOL(c);
45
+ }
46
+
47
+ export function isFlowIndicator(c: number): boolean {
48
+ return (
49
+ c === COMMA ||
50
+ c === LEFT_SQUARE_BRACKET ||
51
+ c === RIGHT_SQUARE_BRACKET ||
52
+ c === LEFT_CURLY_BRACKET ||
53
+ c === RIGHT_CURLY_BRACKET
54
+ );
55
+ }