@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,1004 @@
1
+ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
2
+ // This module is browser compatible.
3
+ // A module to print ANSI terminal colors. Inspired by chalk, kleur, and colors
4
+ // on npm.
5
+
6
+ /**
7
+ * String formatters and utilities for dealing with ANSI color codes.
8
+ *
9
+ * > [!IMPORTANT]
10
+ * > If printing directly to the console, it's recommended to style console
11
+ * > output using CSS (guide
12
+ * > {@linkcode https://developer.mozilla.org/en-US/docs/Web/API/console#styling_console_output | here}).
13
+ *
14
+ * This module supports `NO_COLOR` environmental variable disabling any coloring
15
+ * if `NO_COLOR` is set.
16
+ *
17
+ * ```ts no-assert
18
+ * import {
19
+ * bgBlue,
20
+ * bgRgb24,
21
+ * bgRgb8,
22
+ * bold,
23
+ * italic,
24
+ * red,
25
+ * rgb24,
26
+ * rgb8,
27
+ * } from "@std/fmt/colors";
28
+ *
29
+ * console.log(bgBlue(italic(red(bold("Hello, World!")))));
30
+ *
31
+ * // also supports 8bit colors
32
+ *
33
+ * console.log(rgb8("Hello, World!", 42));
34
+ *
35
+ * console.log(bgRgb8("Hello, World!", 42));
36
+ *
37
+ * // and 24bit rgb
38
+ *
39
+ * console.log(rgb24("Hello, World!", {
40
+ * r: 41,
41
+ * g: 42,
42
+ * b: 43,
43
+ * }));
44
+ *
45
+ * console.log(bgRgb24("Hello, World!", {
46
+ * r: 41,
47
+ * g: 42,
48
+ * b: 43,
49
+ * }));
50
+ * ```
51
+ *
52
+ * @module
53
+ */
54
+
55
+ // deno-lint-ignore no-explicit-any
56
+ import * as dntShim from "../../../../../_dnt.shims.js";
57
+
58
+ const { Deno } = dntShim.dntGlobalThis as any;
59
+ const noColor = typeof Deno?.noColor === "boolean"
60
+ ? Deno.noColor as boolean
61
+ : false;
62
+
63
+ interface Code {
64
+ open: string;
65
+ close: string;
66
+ regexp: RegExp;
67
+ }
68
+
69
+ /** RGB 8-bits per channel. Each in range `0->255` or `0x00->0xff` */
70
+ export interface Rgb {
71
+ /** Red component value */
72
+ r: number;
73
+ /** Green component value */
74
+ g: number;
75
+ /** Blue component value */
76
+ b: number;
77
+ }
78
+
79
+ let enabled = !noColor;
80
+
81
+ /**
82
+ * Enable or disable text color when styling.
83
+ *
84
+ * `@std/fmt/colors` automatically detects NO_COLOR environmental variable
85
+ * and disables text color. Use this API only when the automatic detection
86
+ * doesn't work.
87
+ *
88
+ * @example Usage
89
+ * ```ts no-assert
90
+ * import { setColorEnabled } from "@std/fmt/colors";
91
+ *
92
+ * // Disable text color
93
+ * setColorEnabled(false);
94
+ *
95
+ * // Enable text color
96
+ * setColorEnabled(true);
97
+ * ```
98
+ *
99
+ * @param value The boolean value to enable or disable text color
100
+ */
101
+ export function setColorEnabled(value: boolean) {
102
+ if (Deno?.noColor) {
103
+ return;
104
+ }
105
+
106
+ enabled = value;
107
+ }
108
+
109
+ /**
110
+ * Get whether text color change is enabled or disabled.
111
+ *
112
+ * @example Usage
113
+ * ```ts no-assert
114
+ * import { getColorEnabled } from "@std/fmt/colors";
115
+ *
116
+ * console.log(getColorEnabled()); // true if enabled, false if disabled
117
+ * ```
118
+ * @returns `true` if text color is enabled, `false` otherwise
119
+ */
120
+ export function getColorEnabled(): boolean {
121
+ return enabled;
122
+ }
123
+
124
+ /**
125
+ * Builds color code
126
+ * @param open
127
+ * @param close
128
+ */
129
+ function code(open: number[], close: number): Code {
130
+ return {
131
+ open: `\x1b[${open.join(";")}m`,
132
+ close: `\x1b[${close}m`,
133
+ regexp: new RegExp(`\\x1b\\[${close}m`, "g"),
134
+ };
135
+ }
136
+
137
+ /**
138
+ * Applies color and background based on color code and its associated text
139
+ * @param str The text to apply color settings to
140
+ * @param code The color code to apply
141
+ */
142
+ function run(str: string, code: Code): string {
143
+ return enabled
144
+ ? `${code.open}${str.replace(code.regexp, code.open)}${code.close}`
145
+ : str;
146
+ }
147
+
148
+ /**
149
+ * Reset the text modified.
150
+ *
151
+ * @example Usage
152
+ * ```ts no-assert
153
+ * import { reset } from "@std/fmt/colors";
154
+ *
155
+ * console.log(reset("Hello, world!"));
156
+ * ```
157
+ *
158
+ * @param str The text to reset
159
+ * @returns The text with reset color
160
+ */
161
+ export function reset(str: string): string {
162
+ return run(str, code([0], 0));
163
+ }
164
+
165
+ /**
166
+ * Make the text bold.
167
+ *
168
+ * @example Usage
169
+ * ```ts no-assert
170
+ * import { bold } from "@std/fmt/colors";
171
+ *
172
+ * console.log(bold("Hello, world!"));
173
+ * ```
174
+ *
175
+ * @param str The text to make bold
176
+ * @returns The bold text
177
+ */
178
+ export function bold(str: string): string {
179
+ return run(str, code([1], 22));
180
+ }
181
+
182
+ /**
183
+ * The text emits only a small amount of light.
184
+ *
185
+ * @example Usage
186
+ * ```ts no-assert
187
+ * import { dim } from "@std/fmt/colors";
188
+ *
189
+ * console.log(dim("Hello, world!"));
190
+ * ```
191
+ *
192
+ * @param str The text to dim
193
+ * @returns The dimmed text
194
+ *
195
+ * Warning: Not all terminal emulators support `dim`.
196
+ * For compatibility across all terminals, use {@linkcode gray} or {@linkcode brightBlack} instead.
197
+ */
198
+ export function dim(str: string): string {
199
+ return run(str, code([2], 22));
200
+ }
201
+
202
+ /**
203
+ * Make the text italic.
204
+ *
205
+ * @example Usage
206
+ * ```ts no-assert
207
+ * import { italic } from "@std/fmt/colors";
208
+ *
209
+ * console.log(italic("Hello, world!"));
210
+ * ```
211
+ *
212
+ * @param str The text to make italic
213
+ * @returns The italic text
214
+ */
215
+ export function italic(str: string): string {
216
+ return run(str, code([3], 23));
217
+ }
218
+
219
+ /**
220
+ * Make the text underline.
221
+ *
222
+ * @example Usage
223
+ * ```ts no-assert
224
+ * import { underline } from "@std/fmt/colors";
225
+ *
226
+ * console.log(underline("Hello, world!"));
227
+ * ```
228
+ *
229
+ * @param str The text to underline
230
+ * @returns The underlined text
231
+ */
232
+ export function underline(str: string): string {
233
+ return run(str, code([4], 24));
234
+ }
235
+
236
+ /**
237
+ * Invert background color and text color.
238
+ *
239
+ * @example Usage
240
+ * ```ts no-assert
241
+ * import { inverse } from "@std/fmt/colors";
242
+ *
243
+ * console.log(inverse("Hello, world!"));
244
+ * ```
245
+ *
246
+ * @param str The text to invert its color
247
+ * @returns The inverted text
248
+ */
249
+ export function inverse(str: string): string {
250
+ return run(str, code([7], 27));
251
+ }
252
+
253
+ /**
254
+ * Make the text hidden.
255
+ *
256
+ * @example Usage
257
+ * ```ts no-assert
258
+ * import { hidden } from "@std/fmt/colors";
259
+ *
260
+ * console.log(hidden("Hello, world!"));
261
+ * ```
262
+ *
263
+ * @param str The text to hide
264
+ * @returns The hidden text
265
+ */
266
+ export function hidden(str: string): string {
267
+ return run(str, code([8], 28));
268
+ }
269
+
270
+ /**
271
+ * Put horizontal line through the center of the text.
272
+ *
273
+ * @example Usage
274
+ * ```ts no-assert
275
+ * import { strikethrough } from "@std/fmt/colors";
276
+ *
277
+ * console.log(strikethrough("Hello, world!"));
278
+ * ```
279
+ *
280
+ * @param str The text to strike through
281
+ * @returns The text with horizontal line through the center
282
+ */
283
+ export function strikethrough(str: string): string {
284
+ return run(str, code([9], 29));
285
+ }
286
+
287
+ /**
288
+ * Set text color to black.
289
+ *
290
+ * @example Usage
291
+ * ```ts no-assert
292
+ * import { black } from "@std/fmt/colors";
293
+ *
294
+ * console.log(black("Hello, world!"));
295
+ * ```
296
+ *
297
+ * @param str The text to make black
298
+ * @returns The black text
299
+ */
300
+ export function black(str: string): string {
301
+ return run(str, code([30], 39));
302
+ }
303
+
304
+ /**
305
+ * Set text color to red.
306
+ *
307
+ * @example Usage
308
+ * ```ts no-assert
309
+ * import { red } from "@std/fmt/colors";
310
+ *
311
+ * console.log(red("Hello, world!"));
312
+ * ```
313
+ *
314
+ * @param str The text to make red
315
+ * @returns The red text
316
+ */
317
+ export function red(str: string): string {
318
+ return run(str, code([31], 39));
319
+ }
320
+
321
+ /**
322
+ * Set text color to green.
323
+ *
324
+ * @example Usage
325
+ * ```ts no-assert
326
+ * import { green } from "@std/fmt/colors";
327
+ *
328
+ * console.log(green("Hello, world!"));
329
+ * ```
330
+ *
331
+ * @param str The text to make green
332
+ * @returns The green text
333
+ */
334
+ export function green(str: string): string {
335
+ return run(str, code([32], 39));
336
+ }
337
+
338
+ /**
339
+ * Set text color to yellow.
340
+ *
341
+ * @example Usage
342
+ * ```ts no-assert
343
+ * import { yellow } from "@std/fmt/colors";
344
+ *
345
+ * console.log(yellow("Hello, world!"));
346
+ * ```
347
+ *
348
+ * @param str The text to make yellow
349
+ * @returns The yellow text
350
+ */
351
+ export function yellow(str: string): string {
352
+ return run(str, code([33], 39));
353
+ }
354
+
355
+ /**
356
+ * Set text color to blue.
357
+ *
358
+ * @example Usage
359
+ * ```ts no-assert
360
+ * import { blue } from "@std/fmt/colors";
361
+ *
362
+ * console.log(blue("Hello, world!"));
363
+ * ```
364
+ *
365
+ * @param str The text to make blue
366
+ * @returns The blue text
367
+ */
368
+ export function blue(str: string): string {
369
+ return run(str, code([34], 39));
370
+ }
371
+
372
+ /**
373
+ * Set text color to magenta.
374
+ *
375
+ * @example Usage
376
+ * ```ts no-assert
377
+ * import { magenta } from "@std/fmt/colors";
378
+ *
379
+ * console.log(magenta("Hello, world!"));
380
+ * ```
381
+ *
382
+ * @param str The text to make magenta
383
+ * @returns The magenta text
384
+ */
385
+ export function magenta(str: string): string {
386
+ return run(str, code([35], 39));
387
+ }
388
+
389
+ /**
390
+ * Set text color to cyan.
391
+ *
392
+ * @example Usage
393
+ * ```ts no-assert
394
+ * import { cyan } from "@std/fmt/colors";
395
+ *
396
+ * console.log(cyan("Hello, world!"));
397
+ * ```
398
+ *
399
+ * @param str The text to make cyan
400
+ * @returns The cyan text
401
+ */
402
+ export function cyan(str: string): string {
403
+ return run(str, code([36], 39));
404
+ }
405
+
406
+ /**
407
+ * Set text color to white.
408
+ *
409
+ * @example Usage
410
+ * ```ts no-assert
411
+ * import { white } from "@std/fmt/colors";
412
+ *
413
+ * console.log(white("Hello, world!"));
414
+ * ```
415
+ *
416
+ * @param str The text to make white
417
+ * @returns The white text
418
+ */
419
+ export function white(str: string): string {
420
+ return run(str, code([37], 39));
421
+ }
422
+
423
+ /**
424
+ * Set text color to gray.
425
+ *
426
+ * @example Usage
427
+ * ```ts no-assert
428
+ * import { gray } from "@std/fmt/colors";
429
+ *
430
+ * console.log(gray("Hello, world!"));
431
+ * ```
432
+ *
433
+ * @param str The text to make gray
434
+ * @returns The gray text
435
+ */
436
+ export function gray(str: string): string {
437
+ return brightBlack(str);
438
+ }
439
+
440
+ /**
441
+ * Set text color to bright black.
442
+ *
443
+ * @example Usage
444
+ * ```ts no-assert
445
+ * import { brightBlack } from "@std/fmt/colors";
446
+ *
447
+ * console.log(brightBlack("Hello, world!"));
448
+ * ```
449
+ *
450
+ * @param str The text to make bright black
451
+ * @returns The bright black text
452
+ */
453
+ export function brightBlack(str: string): string {
454
+ return run(str, code([90], 39));
455
+ }
456
+
457
+ /**
458
+ * Set text color to bright red.
459
+ *
460
+ * @example Usage
461
+ * ```ts no-assert
462
+ * import { brightRed } from "@std/fmt/colors";
463
+ *
464
+ * console.log(brightRed("Hello, world!"));
465
+ * ```
466
+ *
467
+ * @param str The text to make bright red
468
+ * @returns The bright red text
469
+ */
470
+ export function brightRed(str: string): string {
471
+ return run(str, code([91], 39));
472
+ }
473
+
474
+ /**
475
+ * Set text color to bright green.
476
+ *
477
+ * @example Usage
478
+ * ```ts no-assert
479
+ * import { brightGreen } from "@std/fmt/colors";
480
+ *
481
+ * console.log(brightGreen("Hello, world!"));
482
+ * ```
483
+ *
484
+ * @param str The text to make bright green
485
+ * @returns The bright green text
486
+ */
487
+ export function brightGreen(str: string): string {
488
+ return run(str, code([92], 39));
489
+ }
490
+
491
+ /**
492
+ * Set text color to bright yellow.
493
+ *
494
+ * @example Usage
495
+ * ```ts no-assert
496
+ * import { brightYellow } from "@std/fmt/colors";
497
+ *
498
+ * console.log(brightYellow("Hello, world!"));
499
+ * ```
500
+ *
501
+ * @param str The text to make bright yellow
502
+ * @returns The bright yellow text
503
+ */
504
+ export function brightYellow(str: string): string {
505
+ return run(str, code([93], 39));
506
+ }
507
+
508
+ /**
509
+ * Set text color to bright blue.
510
+ *
511
+ * @example Usage
512
+ * ```ts no-assert
513
+ * import { brightBlue } from "@std/fmt/colors";
514
+ *
515
+ * console.log(brightBlue("Hello, world!"));
516
+ * ```
517
+ *
518
+ * @param str The text to make bright blue
519
+ * @returns The bright blue text
520
+ */
521
+ export function brightBlue(str: string): string {
522
+ return run(str, code([94], 39));
523
+ }
524
+
525
+ /**
526
+ * Set text color to bright magenta.
527
+ *
528
+ * @example Usage
529
+ * ```ts no-assert
530
+ * import { brightMagenta } from "@std/fmt/colors";
531
+ *
532
+ * console.log(brightMagenta("Hello, world!"));
533
+ * ```
534
+ *
535
+ * @param str The text to make bright magenta
536
+ * @returns The bright magenta text
537
+ */
538
+ export function brightMagenta(str: string): string {
539
+ return run(str, code([95], 39));
540
+ }
541
+
542
+ /**
543
+ * Set text color to bright cyan.
544
+ *
545
+ * @example Usage
546
+ * ```ts no-assert
547
+ * import { brightCyan } from "@std/fmt/colors";
548
+ *
549
+ * console.log(brightCyan("Hello, world!"));
550
+ * ```
551
+ *
552
+ * @param str The text to make bright cyan
553
+ * @returns The bright cyan text
554
+ */
555
+ export function brightCyan(str: string): string {
556
+ return run(str, code([96], 39));
557
+ }
558
+
559
+ /**
560
+ * Set text color to bright white.
561
+ *
562
+ * @example Usage
563
+ * ```ts no-assert
564
+ * import { brightWhite } from "@std/fmt/colors";
565
+ *
566
+ * console.log(brightWhite("Hello, world!"));
567
+ * ```
568
+ *
569
+ * @param str The text to make bright white
570
+ * @returns The bright white text
571
+ */
572
+ export function brightWhite(str: string): string {
573
+ return run(str, code([97], 39));
574
+ }
575
+
576
+ /**
577
+ * Set background color to black.
578
+ *
579
+ * @example Usage
580
+ * ```ts no-assert
581
+ * import { bgBlack } from "@std/fmt/colors";
582
+ *
583
+ * console.log(bgBlack("Hello, world!"));
584
+ * ```
585
+ *
586
+ * @param str The text to make its background black
587
+ * @returns The text with black background
588
+ */
589
+ export function bgBlack(str: string): string {
590
+ return run(str, code([40], 49));
591
+ }
592
+
593
+ /**
594
+ * Set background color to red.
595
+ *
596
+ * @example Usage
597
+ * ```ts no-assert
598
+ * import { bgRed } from "@std/fmt/colors";
599
+ *
600
+ * console.log(bgRed("Hello, world!"));
601
+ * ```
602
+ *
603
+ * @param str The text to make its background red
604
+ * @returns The text with red background
605
+ */
606
+ export function bgRed(str: string): string {
607
+ return run(str, code([41], 49));
608
+ }
609
+
610
+ /**
611
+ * Set background color to green.
612
+ *
613
+ * @example Usage
614
+ * ```ts no-assert
615
+ * import { bgGreen } from "@std/fmt/colors";
616
+ *
617
+ * console.log(bgGreen("Hello, world!"));
618
+ * ```
619
+ *
620
+ * @param str The text to make its background green
621
+ * @returns The text with green background
622
+ */
623
+ export function bgGreen(str: string): string {
624
+ return run(str, code([42], 49));
625
+ }
626
+
627
+ /**
628
+ * Set background color to yellow.
629
+ *
630
+ * @example Usage
631
+ * ```ts no-assert
632
+ * import { bgYellow } from "@std/fmt/colors";
633
+ *
634
+ * console.log(bgYellow("Hello, world!"));
635
+ * ```
636
+ *
637
+ * @param str The text to make its background yellow
638
+ * @returns The text with yellow background
639
+ */
640
+ export function bgYellow(str: string): string {
641
+ return run(str, code([43], 49));
642
+ }
643
+
644
+ /**
645
+ * Set background color to blue.
646
+ *
647
+ * @example Usage
648
+ * ```ts no-assert
649
+ * import { bgBlue } from "@std/fmt/colors";
650
+ *
651
+ * console.log(bgBlue("Hello, world!"));
652
+ * ```
653
+ *
654
+ * @param str The text to make its background blue
655
+ * @returns The text with blue background
656
+ */
657
+ export function bgBlue(str: string): string {
658
+ return run(str, code([44], 49));
659
+ }
660
+
661
+ /**
662
+ * Set background color to magenta.
663
+ *
664
+ * @example Usage
665
+ * ```ts no-assert
666
+ * import { bgMagenta } from "@std/fmt/colors";
667
+ *
668
+ * console.log(bgMagenta("Hello, world!"));
669
+ * ```
670
+ *
671
+ * @param str The text to make its background magenta
672
+ * @returns The text with magenta background
673
+ */
674
+ export function bgMagenta(str: string): string {
675
+ return run(str, code([45], 49));
676
+ }
677
+
678
+ /**
679
+ * Set background color to cyan.
680
+ *
681
+ * @example Usage
682
+ * ```ts no-assert
683
+ * import { bgCyan } from "@std/fmt/colors";
684
+ *
685
+ * console.log(bgCyan("Hello, world!"));
686
+ * ```
687
+ *
688
+ * @param str The text to make its background cyan
689
+ * @returns The text with cyan background
690
+ */
691
+ export function bgCyan(str: string): string {
692
+ return run(str, code([46], 49));
693
+ }
694
+
695
+ /**
696
+ * Set background color to white.
697
+ *
698
+ * @example Usage
699
+ * ```ts no-assert
700
+ * import { bgWhite } from "@std/fmt/colors";
701
+ *
702
+ * console.log(bgWhite("Hello, world!"));
703
+ * ```
704
+ *
705
+ * @param str The text to make its background white
706
+ * @returns The text with white background
707
+ */
708
+ export function bgWhite(str: string): string {
709
+ return run(str, code([47], 49));
710
+ }
711
+
712
+ /**
713
+ * Set background color to bright black.
714
+ *
715
+ * @example Usage
716
+ * ```ts no-assert
717
+ * import { bgBrightBlack } from "@std/fmt/colors";
718
+ *
719
+ * console.log(bgBrightBlack("Hello, world!"));
720
+ * ```
721
+ *
722
+ * @param str The text to make its background bright black
723
+ * @returns The text with bright black background
724
+ */
725
+ export function bgBrightBlack(str: string): string {
726
+ return run(str, code([100], 49));
727
+ }
728
+
729
+ /**
730
+ * Set background color to bright red.
731
+ *
732
+ * @example Usage
733
+ * ```ts no-assert
734
+ * import { bgBrightRed } from "@std/fmt/colors";
735
+ *
736
+ * console.log(bgBrightRed("Hello, world!"));
737
+ * ```
738
+ *
739
+ * @param str The text to make its background bright red
740
+ * @returns The text with bright red background
741
+ */
742
+ export function bgBrightRed(str: string): string {
743
+ return run(str, code([101], 49));
744
+ }
745
+
746
+ /**
747
+ * Set background color to bright green.
748
+ *
749
+ * @example Usage
750
+ * ```ts no-assert
751
+ * import { bgBrightGreen } from "@std/fmt/colors";
752
+ *
753
+ * console.log(bgBrightGreen("Hello, world!"));
754
+ * ```
755
+ *
756
+ * @param str The text to make its background bright green
757
+ * @returns The text with bright green background
758
+ */
759
+ export function bgBrightGreen(str: string): string {
760
+ return run(str, code([102], 49));
761
+ }
762
+
763
+ /**
764
+ * Set background color to bright yellow.
765
+ *
766
+ * @example Usage
767
+ * ```ts no-assert
768
+ * import { bgBrightYellow } from "@std/fmt/colors";
769
+ *
770
+ * console.log(bgBrightYellow("Hello, world!"));
771
+ * ```
772
+ *
773
+ * @param str The text to make its background bright yellow
774
+ * @returns The text with bright yellow background
775
+ */
776
+ export function bgBrightYellow(str: string): string {
777
+ return run(str, code([103], 49));
778
+ }
779
+
780
+ /**
781
+ * Set background color to bright blue.
782
+ *
783
+ * @example Usage
784
+ * ```ts no-assert
785
+ * import { bgBrightBlue } from "@std/fmt/colors";
786
+ *
787
+ * console.log(bgBrightBlue("Hello, world!"));
788
+ * ```
789
+ *
790
+ * @param str The text to make its background bright blue
791
+ * @returns The text with bright blue background
792
+ */
793
+ export function bgBrightBlue(str: string): string {
794
+ return run(str, code([104], 49));
795
+ }
796
+
797
+ /**
798
+ * Set background color to bright magenta.
799
+ *
800
+ * @example Usage
801
+ * ```ts no-assert
802
+ * import { bgBrightMagenta } from "@std/fmt/colors";
803
+ *
804
+ * console.log(bgBrightMagenta("Hello, world!"));
805
+ * ```
806
+ *
807
+ * @param str The text to make its background bright magenta
808
+ * @returns The text with bright magenta background
809
+ */
810
+ export function bgBrightMagenta(str: string): string {
811
+ return run(str, code([105], 49));
812
+ }
813
+
814
+ /**
815
+ * Set background color to bright cyan.
816
+ *
817
+ * @example Usage
818
+ * ```ts no-assert
819
+ * import { bgBrightCyan } from "@std/fmt/colors";
820
+ *
821
+ * console.log(bgBrightCyan("Hello, world!"));
822
+ * ```
823
+ *
824
+ * @param str The text to make its background bright cyan
825
+ * @returns The text with bright cyan background
826
+ */
827
+ export function bgBrightCyan(str: string): string {
828
+ return run(str, code([106], 49));
829
+ }
830
+
831
+ /**
832
+ * Set background color to bright white.
833
+ *
834
+ * @example Usage
835
+ * ```ts no-assert
836
+ * import { bgBrightWhite } from "@std/fmt/colors";
837
+ *
838
+ * console.log(bgBrightWhite("Hello, world!"));
839
+ * ```
840
+ *
841
+ * @param str The text to make its background bright white
842
+ * @returns The text with bright white background
843
+ */
844
+ export function bgBrightWhite(str: string): string {
845
+ return run(str, code([107], 49));
846
+ }
847
+
848
+ /* Special Color Sequences */
849
+
850
+ /**
851
+ * Clam and truncate color codes
852
+ * @param n The input number
853
+ * @param max The number to truncate to
854
+ * @param min The number to truncate from
855
+ */
856
+ function clampAndTruncate(n: number, max = 255, min = 0): number {
857
+ return Math.trunc(Math.max(Math.min(n, max), min));
858
+ }
859
+
860
+ /**
861
+ * Set text color using paletted 8bit colors.
862
+ * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
863
+ *
864
+ * @example Usage
865
+ * ```ts no-assert
866
+ * import { rgb8 } from "@std/fmt/colors";
867
+ *
868
+ * console.log(rgb8("Hello, world!", 42));
869
+ * ```
870
+ *
871
+ * @param str The text color to apply paletted 8bit colors to
872
+ * @param color The color code
873
+ * @returns The text with paletted 8bit color
874
+ */
875
+ export function rgb8(str: string, color: number): string {
876
+ return run(str, code([38, 5, clampAndTruncate(color)], 39));
877
+ }
878
+
879
+ /**
880
+ * Set background color using paletted 8bit colors.
881
+ * https://en.wikipedia.org/wiki/ANSI_escape_code#8-bit
882
+ *
883
+ * @example Usage
884
+ * ```ts no-assert
885
+ * import { bgRgb8 } from "@std/fmt/colors";
886
+ *
887
+ * console.log(bgRgb8("Hello, world!", 42));
888
+ * ```
889
+ *
890
+ * @param str The text color to apply paletted 8bit background colors to
891
+ * @param color code
892
+ * @returns The text with paletted 8bit background color
893
+ */
894
+ export function bgRgb8(str: string, color: number): string {
895
+ return run(str, code([48, 5, clampAndTruncate(color)], 49));
896
+ }
897
+
898
+ /**
899
+ * Set text color using 24bit rgb.
900
+ * `color` can be a number in range `0x000000` to `0xffffff` or
901
+ * an `Rgb`.
902
+ *
903
+ * @example To produce the color magenta:
904
+ * ```ts no-assert
905
+ * import { rgb24 } from "@std/fmt/colors";
906
+ *
907
+ * rgb24("foo", 0xff00ff);
908
+ * rgb24("foo", {r: 255, g: 0, b: 255});
909
+ * ```
910
+ * @param str The text color to apply 24bit rgb to
911
+ * @param color The color code
912
+ * @returns The text with 24bit rgb color
913
+ */
914
+ export function rgb24(str: string, color: number | Rgb): string {
915
+ if (typeof color === "number") {
916
+ return run(
917
+ str,
918
+ code(
919
+ [38, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff],
920
+ 39,
921
+ ),
922
+ );
923
+ }
924
+ return run(
925
+ str,
926
+ code(
927
+ [
928
+ 38,
929
+ 2,
930
+ clampAndTruncate(color.r),
931
+ clampAndTruncate(color.g),
932
+ clampAndTruncate(color.b),
933
+ ],
934
+ 39,
935
+ ),
936
+ );
937
+ }
938
+
939
+ /**
940
+ * Set background color using 24bit rgb.
941
+ * `color` can be a number in range `0x000000` to `0xffffff` or
942
+ * an `Rgb`.
943
+ *
944
+ * @example To produce the color magenta:
945
+ * ```ts no-assert
946
+ * import { bgRgb24 } from "@std/fmt/colors";
947
+ *
948
+ * bgRgb24("foo", 0xff00ff);
949
+ * bgRgb24("foo", {r: 255, g: 0, b: 255});
950
+ * ```
951
+ * @param str The text color to apply 24bit rgb to
952
+ * @param color The color code
953
+ * @returns The text with 24bit rgb color
954
+ */
955
+ export function bgRgb24(str: string, color: number | Rgb): string {
956
+ if (typeof color === "number") {
957
+ return run(
958
+ str,
959
+ code(
960
+ [48, 2, (color >> 16) & 0xff, (color >> 8) & 0xff, color & 0xff],
961
+ 49,
962
+ ),
963
+ );
964
+ }
965
+ return run(
966
+ str,
967
+ code(
968
+ [
969
+ 48,
970
+ 2,
971
+ clampAndTruncate(color.r),
972
+ clampAndTruncate(color.g),
973
+ clampAndTruncate(color.b),
974
+ ],
975
+ 49,
976
+ ),
977
+ );
978
+ }
979
+
980
+ // https://github.com/chalk/ansi-regex/blob/02fa893d619d3da85411acc8fd4e2eea0e95a9d9/index.js
981
+ const ANSI_PATTERN = new RegExp(
982
+ [
983
+ "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
984
+ "(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TXZcf-nq-uy=><~]))",
985
+ ].join("|"),
986
+ "g",
987
+ );
988
+
989
+ /**
990
+ * Remove ANSI escape codes from the string.
991
+ *
992
+ * @example Usage
993
+ * ```ts no-assert
994
+ * import { stripAnsiCode, red } from "@std/fmt/colors";
995
+ *
996
+ * console.log(stripAnsiCode(red("Hello, world!")));
997
+ * ```
998
+ *
999
+ * @param string The text to remove ANSI escape codes from
1000
+ * @returns The text without ANSI escape codes
1001
+ */
1002
+ export function stripAnsiCode(string: string): string {
1003
+ return string.replace(ANSI_PATTERN, "");
1004
+ }