@feiyoug/skill-lab 0.0.1 → 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.
- package/README.md +20 -21
- package/esm/analyzer/astgrep/client.d.ts +20 -8
- package/esm/analyzer/astgrep/client.d.ts.map +1 -1
- package/esm/analyzer/astgrep/client.js +58 -31
- package/esm/analyzer/config/default.d.ts +8 -0
- package/esm/analyzer/config/default.d.ts.map +1 -0
- package/esm/analyzer/config/default.js +91 -0
- package/esm/analyzer/config/helpers.d.ts +8 -0
- package/esm/analyzer/config/helpers.d.ts.map +1 -0
- package/esm/analyzer/config/helpers.js +72 -0
- package/esm/analyzer/config/mod.d.ts +4 -0
- package/esm/analyzer/config/mod.d.ts.map +1 -0
- package/esm/analyzer/config/mod.js +3 -0
- package/esm/analyzer/config/types.d.ts +58 -0
- package/esm/analyzer/config/types.d.ts.map +1 -0
- package/esm/analyzer/{config.js → config/types.js} +0 -28
- package/esm/analyzer/logging.d.ts +3 -0
- package/esm/analyzer/logging.d.ts.map +1 -0
- package/esm/analyzer/logging.js +6 -0
- package/esm/analyzer/mod.d.ts +12 -5
- package/esm/analyzer/mod.d.ts.map +1 -1
- package/esm/analyzer/mod.js +25 -12
- package/esm/analyzer/result.d.ts +35 -0
- package/esm/analyzer/result.d.ts.map +1 -0
- package/esm/analyzer/result.js +311 -0
- package/esm/analyzer/rules/bash/commands/mod.d.ts +1 -0
- package/esm/analyzer/rules/bash/commands/mod.d.ts.map +1 -1
- package/esm/analyzer/rules/bash/commands/mod.js +3 -0
- package/esm/analyzer/rules/bash/commands/pip.d.ts +3 -0
- package/esm/analyzer/rules/bash/commands/pip.d.ts.map +1 -0
- package/esm/analyzer/rules/bash/commands/pip.js +14 -0
- package/esm/analyzer/rules/bash/extractFileRefs.d.ts +1 -1
- package/esm/analyzer/rules/bash/extractFileRefs.d.ts.map +1 -1
- package/esm/analyzer/rules/bash/extractFileRefs.js +2 -2
- package/esm/analyzer/rules/bash/inline-command-classifier.d.ts +1 -1
- package/esm/analyzer/rules/bash/inline-command-classifier.d.ts.map +1 -1
- package/esm/analyzer/rules/bash/inline-command-classifier.js +4 -4
- package/esm/analyzer/rules/javascript/extractFileRefs.d.ts +3 -4
- package/esm/analyzer/rules/javascript/extractFileRefs.d.ts.map +1 -1
- package/esm/analyzer/rules/javascript/extractFileRefs.js +3 -4
- package/esm/analyzer/rules/markdown/extractCodeBlocks.d.ts.map +1 -1
- package/esm/analyzer/rules/markdown/extractCodeBlocks.js +6 -3
- package/esm/analyzer/rules/markdown/extractFileRefs.d.ts.map +1 -1
- package/esm/analyzer/rules/markdown/extractFileRefs.js +2 -0
- package/esm/analyzer/rules/python/extractFileRefs.d.ts +1 -1
- package/esm/analyzer/rules/python/extractFileRefs.d.ts.map +1 -1
- package/esm/analyzer/rules/python/extractFileRefs.js +2 -2
- package/esm/analyzer/steps/001-discovery/discover-files.d.ts +4 -0
- package/esm/analyzer/steps/001-discovery/discover-files.d.ts.map +1 -1
- package/esm/analyzer/steps/001-discovery/discover-files.js +18 -2
- package/esm/analyzer/steps/001-discovery/mod.d.ts.map +1 -1
- package/esm/analyzer/steps/001-discovery/mod.js +39 -9
- package/esm/analyzer/steps/002-permissions/mod.d.ts.map +1 -1
- package/esm/analyzer/steps/002-permissions/mod.js +156 -73
- package/esm/analyzer/steps/002-permissions/scan-file.d.ts +1 -1
- package/esm/analyzer/steps/002-permissions/scan-file.d.ts.map +1 -1
- package/esm/analyzer/steps/002-permissions/scan-file.js +40 -5
- package/esm/analyzer/steps/002-permissions/seed-frontmatter.js +2 -2
- package/esm/analyzer/steps/003-risks/dep-risks.d.ts +3 -0
- package/esm/analyzer/steps/003-risks/dep-risks.d.ts.map +1 -0
- package/esm/analyzer/steps/003-risks/dep-risks.js +74 -0
- package/esm/analyzer/steps/003-risks/helpers.d.ts +1 -0
- package/esm/analyzer/steps/003-risks/helpers.d.ts.map +1 -1
- package/esm/analyzer/steps/003-risks/helpers.js +1 -0
- package/esm/analyzer/steps/003-risks/mod.d.ts +3 -2
- package/esm/analyzer/steps/003-risks/mod.d.ts.map +1 -1
- package/esm/analyzer/steps/003-risks/mod.js +41 -4
- package/esm/analyzer/steps/003-risks/policy.d.ts +7 -0
- package/esm/analyzer/steps/003-risks/policy.d.ts.map +1 -0
- package/esm/analyzer/steps/003-risks/policy.js +23 -0
- package/esm/analyzer/steps/003-risks/rule-mapped.d.ts +2 -2
- package/esm/analyzer/steps/003-risks/rule-mapped.d.ts.map +1 -1
- package/esm/analyzer/steps/003-risks/rule-mapped.js +83 -2
- package/esm/analyzer/steps/003-risks/scoring.d.ts +9 -1
- package/esm/analyzer/steps/003-risks/scoring.d.ts.map +1 -1
- package/esm/analyzer/steps/003-risks/scoring.js +55 -42
- package/esm/analyzer/treesitter/client.d.ts +31 -0
- package/esm/analyzer/treesitter/client.d.ts.map +1 -0
- package/esm/analyzer/{treesiter → treesitter}/client.js +43 -39
- package/esm/analyzer/treesitter/registry.d.ts +73 -0
- package/esm/analyzer/treesitter/registry.d.ts.map +1 -0
- package/esm/analyzer/treesitter/registry.js +165 -0
- package/esm/analyzer/types.d.ts +14 -28
- package/esm/analyzer/types.d.ts.map +1 -1
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/deps.d.ts +3 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/deps.d.ts.map +1 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/deps.js +3 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/mod.d.ts +93 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/mod.d.ts.map +1 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/mod.js +297 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/multi.d.ts +84 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/multi.d.ts.map +1 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/multi.js +268 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/time.d.ts +18 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/time.d.ts.map +1 -0
- package/esm/deps/jsr.io/@deno-library/progress/1.5.1/time.js +45 -0
- package/esm/deps/jsr.io/@std/fmt/1.0.3/colors.d.ts +700 -0
- package/esm/deps/jsr.io/@std/fmt/1.0.3/colors.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/fmt/1.0.3/colors.js +903 -0
- package/esm/deps/jsr.io/@std/io/0.225.0/types.d.ts +146 -0
- package/esm/deps/jsr.io/@std/io/0.225.0/types.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.0/types.js +15 -0
- package/esm/deps/jsr.io/@std/io/0.225.0/write_all.d.ts +51 -0
- package/esm/deps/jsr.io/@std/io/0.225.0/write_all.d.ts.map +1 -0
- package/esm/deps/jsr.io/@std/io/0.225.0/write_all.js +61 -0
- package/esm/shared/deep_merge.d.ts +12 -0
- package/esm/shared/deep_merge.d.ts.map +1 -0
- package/esm/shared/deep_merge.js +49 -0
- package/esm/shared/mod.d.ts +1 -0
- package/esm/shared/mod.d.ts.map +1 -1
- package/esm/shared/mod.js +1 -0
- package/esm/shared/types/filetypes.d.ts +2 -2
- package/esm/shared/types/filetypes.d.ts.map +1 -1
- package/esm/shared/types/permissions.d.ts +1 -1
- package/esm/shared/types/permissions.d.ts.map +1 -1
- package/esm/shared/types/risks.d.ts +4 -1
- package/esm/shared/types/risks.d.ts.map +1 -1
- package/esm/skillreader/types.d.ts +2 -2
- package/esm/skillreader/types.d.ts.map +1 -1
- package/esm/skillreader/types.js +2 -2
- package/package.json +1 -1
- package/script/analyzer/astgrep/client.d.ts +20 -8
- package/script/analyzer/astgrep/client.d.ts.map +1 -1
- package/script/analyzer/astgrep/client.js +58 -64
- package/script/analyzer/config/default.d.ts +8 -0
- package/script/analyzer/config/default.d.ts.map +1 -0
- package/script/analyzer/config/default.js +94 -0
- package/script/analyzer/config/helpers.d.ts +8 -0
- package/script/analyzer/config/helpers.d.ts.map +1 -0
- package/script/analyzer/config/helpers.js +76 -0
- package/script/analyzer/config/mod.d.ts +4 -0
- package/script/analyzer/config/mod.d.ts.map +1 -0
- package/script/analyzer/config/mod.js +21 -0
- package/script/analyzer/config/types.d.ts +58 -0
- package/script/analyzer/config/types.d.ts.map +1 -0
- package/script/analyzer/{config.js → config/types.js} +1 -29
- package/script/analyzer/logging.d.ts +3 -0
- package/script/analyzer/logging.d.ts.map +1 -0
- package/script/analyzer/logging.js +9 -0
- package/script/analyzer/mod.d.ts +12 -5
- package/script/analyzer/mod.d.ts.map +1 -1
- package/script/analyzer/mod.js +35 -20
- package/script/analyzer/result.d.ts +35 -0
- package/script/analyzer/result.d.ts.map +1 -0
- package/script/analyzer/result.js +315 -0
- package/script/analyzer/rules/bash/commands/mod.d.ts +1 -0
- package/script/analyzer/rules/bash/commands/mod.d.ts.map +1 -1
- package/script/analyzer/rules/bash/commands/mod.js +3 -0
- package/script/analyzer/rules/bash/commands/pip.d.ts +3 -0
- package/script/analyzer/rules/bash/commands/pip.d.ts.map +1 -0
- package/script/analyzer/rules/bash/commands/pip.js +17 -0
- package/script/analyzer/rules/bash/extractFileRefs.d.ts +1 -1
- package/script/analyzer/rules/bash/extractFileRefs.d.ts.map +1 -1
- package/script/analyzer/rules/bash/extractFileRefs.js +2 -2
- package/script/analyzer/rules/bash/inline-command-classifier.d.ts +1 -1
- package/script/analyzer/rules/bash/inline-command-classifier.d.ts.map +1 -1
- package/script/analyzer/rules/bash/inline-command-classifier.js +4 -4
- package/script/analyzer/rules/javascript/extractFileRefs.d.ts +3 -4
- package/script/analyzer/rules/javascript/extractFileRefs.d.ts.map +1 -1
- package/script/analyzer/rules/javascript/extractFileRefs.js +3 -4
- package/script/analyzer/rules/markdown/extractCodeBlocks.d.ts.map +1 -1
- package/script/analyzer/rules/markdown/extractCodeBlocks.js +6 -3
- package/script/analyzer/rules/markdown/extractFileRefs.d.ts.map +1 -1
- package/script/analyzer/rules/markdown/extractFileRefs.js +2 -0
- package/script/analyzer/rules/python/extractFileRefs.d.ts +1 -1
- package/script/analyzer/rules/python/extractFileRefs.d.ts.map +1 -1
- package/script/analyzer/rules/python/extractFileRefs.js +2 -2
- package/script/analyzer/steps/001-discovery/discover-files.d.ts +4 -0
- package/script/analyzer/steps/001-discovery/discover-files.d.ts.map +1 -1
- package/script/analyzer/steps/001-discovery/discover-files.js +18 -2
- package/script/analyzer/steps/001-discovery/mod.d.ts.map +1 -1
- package/script/analyzer/steps/001-discovery/mod.js +77 -11
- package/script/analyzer/steps/002-permissions/mod.d.ts.map +1 -1
- package/script/analyzer/steps/002-permissions/mod.js +194 -75
- package/script/analyzer/steps/002-permissions/scan-file.d.ts +1 -1
- package/script/analyzer/steps/002-permissions/scan-file.d.ts.map +1 -1
- package/script/analyzer/steps/002-permissions/scan-file.js +40 -5
- package/script/analyzer/steps/002-permissions/seed-frontmatter.js +3 -3
- package/script/analyzer/steps/003-risks/dep-risks.d.ts +3 -0
- package/script/analyzer/steps/003-risks/dep-risks.d.ts.map +1 -0
- package/script/analyzer/steps/003-risks/dep-risks.js +77 -0
- package/script/analyzer/steps/003-risks/helpers.d.ts +1 -0
- package/script/analyzer/steps/003-risks/helpers.d.ts.map +1 -1
- package/script/analyzer/steps/003-risks/helpers.js +1 -0
- package/script/analyzer/steps/003-risks/mod.d.ts +3 -2
- package/script/analyzer/steps/003-risks/mod.d.ts.map +1 -1
- package/script/analyzer/steps/003-risks/mod.js +77 -4
- package/script/analyzer/steps/003-risks/policy.d.ts +7 -0
- package/script/analyzer/steps/003-risks/policy.d.ts.map +1 -0
- package/script/analyzer/steps/003-risks/policy.js +29 -0
- package/script/analyzer/steps/003-risks/rule-mapped.d.ts +2 -2
- package/script/analyzer/steps/003-risks/rule-mapped.d.ts.map +1 -1
- package/script/analyzer/steps/003-risks/rule-mapped.js +83 -2
- package/script/analyzer/steps/003-risks/scoring.d.ts +9 -1
- package/script/analyzer/steps/003-risks/scoring.d.ts.map +1 -1
- package/script/analyzer/steps/003-risks/scoring.js +55 -42
- package/script/analyzer/treesitter/client.d.ts +31 -0
- package/script/analyzer/treesitter/client.d.ts.map +1 -0
- package/script/analyzer/treesitter/client.js +136 -0
- package/script/analyzer/treesitter/registry.d.ts +73 -0
- package/script/analyzer/treesitter/registry.d.ts.map +1 -0
- package/script/analyzer/treesitter/registry.js +206 -0
- package/script/analyzer/types.d.ts +14 -28
- package/script/analyzer/types.d.ts.map +1 -1
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/deps.d.ts +3 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/deps.d.ts.map +1 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/deps.js +10 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/mod.d.ts +93 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/mod.d.ts.map +1 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/mod.js +334 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/multi.d.ts +84 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/multi.d.ts.map +1 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/multi.js +305 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/time.d.ts +18 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/time.d.ts.map +1 -0
- package/script/deps/jsr.io/@deno-library/progress/1.5.1/time.js +48 -0
- package/script/deps/jsr.io/@std/fmt/1.0.3/colors.d.ts +700 -0
- package/script/deps/jsr.io/@std/fmt/1.0.3/colors.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/fmt/1.0.3/colors.js +986 -0
- package/script/deps/jsr.io/@std/io/0.225.0/types.d.ts +146 -0
- package/script/deps/jsr.io/@std/io/0.225.0/types.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.0/types.js +18 -0
- package/script/deps/jsr.io/@std/io/0.225.0/write_all.d.ts +51 -0
- package/script/deps/jsr.io/@std/io/0.225.0/write_all.d.ts.map +1 -0
- package/script/deps/jsr.io/@std/io/0.225.0/write_all.js +65 -0
- package/script/shared/deep_merge.d.ts +12 -0
- package/script/shared/deep_merge.d.ts.map +1 -0
- package/script/shared/deep_merge.js +53 -0
- package/script/shared/mod.d.ts +1 -0
- package/script/shared/mod.d.ts.map +1 -1
- package/script/shared/mod.js +1 -0
- package/script/shared/types/filetypes.d.ts +2 -2
- package/script/shared/types/filetypes.d.ts.map +1 -1
- package/script/shared/types/permissions.d.ts +1 -1
- package/script/shared/types/permissions.d.ts.map +1 -1
- package/script/shared/types/risks.d.ts +4 -1
- package/script/shared/types/risks.d.ts.map +1 -1
- package/script/skillreader/types.d.ts +2 -2
- package/script/skillreader/types.d.ts.map +1 -1
- package/script/skillreader/types.js +2 -2
- package/src/_dnt.polyfills.ts +27 -0
- package/src/_dnt.shims.ts +64 -0
- package/src/analyzer/astgrep/client.ts +184 -0
- package/src/analyzer/astgrep/mod.ts +2 -0
- package/src/analyzer/config/default.ts +98 -0
- package/src/analyzer/config/helpers.ts +107 -0
- package/src/analyzer/config/mod.ts +3 -0
- package/src/analyzer/config/types.ts +103 -0
- package/src/analyzer/logging.ts +8 -0
- package/src/analyzer/mod.ts +118 -0
- package/src/analyzer/result.ts +393 -0
- package/src/analyzer/rules/bash/astTypes.ts +5 -0
- package/src/analyzer/rules/bash/commands/bd.ts +23 -0
- package/src/analyzer/rules/bash/commands/cron.ts +21 -0
- package/src/analyzer/rules/bash/commands/docker.ts +37 -0
- package/src/analyzer/rules/bash/commands/eval.ts +52 -0
- package/src/analyzer/rules/bash/commands/generic.ts +16 -0
- package/src/analyzer/rules/bash/commands/gh.ts +21 -0
- package/src/analyzer/rules/bash/commands/git.ts +28 -0
- package/src/analyzer/rules/bash/commands/mod.ts +38 -0
- package/src/analyzer/rules/bash/commands/node.ts +64 -0
- package/src/analyzer/rules/bash/commands/openspec.ts +16 -0
- package/src/analyzer/rules/bash/commands/pip.ts +16 -0
- package/src/analyzer/rules/bash/commands/sudo.ts +21 -0
- package/src/analyzer/rules/bash/destructive.ts +28 -0
- package/src/analyzer/rules/bash/extractFileRefs.ts +101 -0
- package/src/analyzer/rules/bash/filesystem.ts +50 -0
- package/src/analyzer/rules/bash/injection.ts +21 -0
- package/src/analyzer/rules/bash/inline-command-classifier.ts +94 -0
- package/src/analyzer/rules/bash/mod.ts +23 -0
- package/src/analyzer/rules/bash/network.ts +64 -0
- package/src/analyzer/rules/bash/secret-detection.ts +43 -0
- package/src/analyzer/rules/javascript/astTypes.ts +8 -0
- package/src/analyzer/rules/javascript/extractFileRefs.ts +131 -0
- package/src/analyzer/rules/javascript/filesystem.ts +28 -0
- package/src/analyzer/rules/javascript/injection.ts +21 -0
- package/src/analyzer/rules/javascript/mod.ts +26 -0
- package/src/analyzer/rules/javascript/network.ts +27 -0
- package/src/analyzer/rules/javascript/secret-detection.ts +68 -0
- package/src/analyzer/rules/javascript/subprocess.ts +16 -0
- package/src/analyzer/rules/markdown/astTypes.ts +35 -0
- package/src/analyzer/rules/markdown/extractCodeBlocks.ts +101 -0
- package/src/analyzer/rules/markdown/extractFileRefs.ts +179 -0
- package/src/analyzer/rules/markdown/mod.ts +12 -0
- package/src/analyzer/rules/mod.ts +77 -0
- package/src/analyzer/rules/python/astTypes.ts +9 -0
- package/src/analyzer/rules/python/extractFileRefs.ts +92 -0
- package/src/analyzer/rules/python/mod.ts +15 -0
- package/src/analyzer/rules/python/network.ts +26 -0
- package/src/analyzer/rules/python/secret-detection.ts +30 -0
- package/src/analyzer/rules/shared/file-refs.ts +38 -0
- package/src/analyzer/rules/shared/network-evaluators.ts +107 -0
- package/src/analyzer/rules/shared/prompt-injection.ts +48 -0
- package/src/analyzer/rules/shared/secret-evaluators.ts +13 -0
- package/src/analyzer/rules/text/mod.ts +12 -0
- package/src/analyzer/rules/typescript/mod.ts +7 -0
- package/src/analyzer/steps/001-discovery/discover-files.ts +211 -0
- package/src/analyzer/steps/001-discovery/filter-files.ts +72 -0
- package/src/analyzer/steps/001-discovery/mod.ts +103 -0
- package/src/analyzer/steps/002-permissions/mod.ts +329 -0
- package/src/analyzer/steps/002-permissions/scan-file.ts +258 -0
- package/src/analyzer/steps/002-permissions/seed-frontmatter.ts +66 -0
- package/src/analyzer/steps/002-permissions/synthesize.ts +42 -0
- package/src/analyzer/steps/003-risks/dep-risks.ts +89 -0
- package/src/analyzer/steps/003-risks/helpers.ts +41 -0
- package/src/analyzer/steps/003-risks/mod.ts +86 -0
- package/src/analyzer/steps/003-risks/policy.ts +38 -0
- package/src/analyzer/steps/003-risks/rule-mapped.ts +206 -0
- package/src/analyzer/steps/003-risks/scoring.ts +117 -0
- package/src/analyzer/steps/mod.ts +3 -0
- package/src/analyzer/treesitter/client.ts +120 -0
- package/src/analyzer/treesitter/registry.ts +198 -0
- package/src/analyzer/types.ts +78 -0
- package/src/analyzer/utils/code-block-path.ts +33 -0
- package/src/analyzer/utils/id-generator.ts +59 -0
- package/src/analyzer/utils/secret-validator.ts +29 -0
- package/src/analyzer/utils/url-parser.ts +25 -0
- package/src/deps/jsr.io/@deno-library/progress/1.5.1/deps.ts +3 -0
- package/src/deps/jsr.io/@deno-library/progress/1.5.1/mod.ts +265 -0
- package/src/deps/jsr.io/@deno-library/progress/1.5.1/multi.ts +250 -0
- package/src/deps/jsr.io/@deno-library/progress/1.5.1/time.ts +69 -0
- package/src/deps/jsr.io/@std/fmt/1.0.3/colors.ts +1004 -0
- package/src/deps/jsr.io/@std/internal/1.0.12/_os.ts +15 -0
- package/src/deps/jsr.io/@std/internal/1.0.12/os.ts +7 -0
- package/src/deps/jsr.io/@std/io/0.225.0/types.ts +157 -0
- package/src/deps/jsr.io/@std/io/0.225.0/write_all.ts +65 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/assert_path.ts +10 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/basename.ts +53 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/common.ts +26 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/constants.ts +49 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/dirname.ts +9 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/format.ts +25 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/from_file_url.ts +12 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/glob_to_reg_exp.ts +295 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/normalize.ts +9 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/normalize_string.ts +74 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/relative.ts +10 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/strip_trailing_separators.ts +25 -0
- package/src/deps/jsr.io/@std/path/1.1.4/_common/to_file_url.ts +17 -0
- package/src/deps/jsr.io/@std/path/1.1.4/basename.ts +37 -0
- package/src/deps/jsr.io/@std/path/1.1.4/common.ts +35 -0
- package/src/deps/jsr.io/@std/path/1.1.4/constants.ts +18 -0
- package/src/deps/jsr.io/@std/path/1.1.4/dirname.ts +30 -0
- package/src/deps/jsr.io/@std/path/1.1.4/extname.ts +29 -0
- package/src/deps/jsr.io/@std/path/1.1.4/format.ts +30 -0
- package/src/deps/jsr.io/@std/path/1.1.4/from_file_url.ts +30 -0
- package/src/deps/jsr.io/@std/path/1.1.4/glob_to_regexp.ts +94 -0
- package/src/deps/jsr.io/@std/path/1.1.4/is_absolute.ts +30 -0
- package/src/deps/jsr.io/@std/path/1.1.4/is_glob.ts +49 -0
- package/src/deps/jsr.io/@std/path/1.1.4/join.ts +31 -0
- package/src/deps/jsr.io/@std/path/1.1.4/join_globs.ts +42 -0
- package/src/deps/jsr.io/@std/path/1.1.4/mod.ts +217 -0
- package/src/deps/jsr.io/@std/path/1.1.4/normalize.ts +33 -0
- package/src/deps/jsr.io/@std/path/1.1.4/normalize_glob.ts +45 -0
- package/src/deps/jsr.io/@std/path/1.1.4/parse.ts +44 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/_util.ts +10 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/basename.ts +62 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/constants.ts +15 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/dirname.ts +72 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/extname.ts +96 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/format.ts +31 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/from_file_url.ts +25 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/glob_to_regexp.ts +94 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/is_absolute.ts +25 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/join.ts +46 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/join_globs.ts +45 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/normalize.ts +63 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/normalize_glob.ts +43 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/parse.ts +121 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/relative.ts +103 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/resolve.ts +71 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/to_file_url.ts +32 -0
- package/src/deps/jsr.io/@std/path/1.1.4/posix/to_namespaced_path.ts +21 -0
- package/src/deps/jsr.io/@std/path/1.1.4/relative.ts +32 -0
- package/src/deps/jsr.io/@std/path/1.1.4/resolve.ts +32 -0
- package/src/deps/jsr.io/@std/path/1.1.4/to_file_url.ts +30 -0
- package/src/deps/jsr.io/@std/path/1.1.4/to_namespaced_path.ts +31 -0
- package/src/deps/jsr.io/@std/path/1.1.4/types.ts +40 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/_util.ts +28 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/basename.ts +54 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/constants.ts +15 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/dirname.ts +118 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/extname.ts +90 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/format.ts +31 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/from_file_url.ts +34 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/glob_to_regexp.ts +92 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/is_absolute.ts +40 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/join.ts +78 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/join_globs.ts +46 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/normalize.ts +136 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/normalize_glob.ts +43 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/parse.ts +184 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/relative.ts +128 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/resolve.ts +178 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/to_file_url.ts +38 -0
- package/src/deps/jsr.io/@std/path/1.1.4/windows/to_namespaced_path.ts +60 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_chars.ts +55 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_dumper_state.ts +841 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_loader_state.ts +1780 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_schema.ts +183 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/binary.ts +127 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/bool.ts +37 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/float.ts +112 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/int.ts +174 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/map.ts +17 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/merge.ts +13 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/nil.ts +27 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/omap.ts +30 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/pairs.ts +22 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/regexp.ts +33 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/seq.ts +13 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/set.ts +17 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/str.ts +12 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/timestamp.ts +101 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type/undefined.ts +23 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_type.ts +49 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/_utils.ts +16 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/mod.ts +54 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/parse.ts +128 -0
- package/src/deps/jsr.io/@std/yaml/1.0.11/stringify.ts +118 -0
- package/src/shared/deep_merge.ts +73 -0
- package/src/shared/mod.ts +2 -0
- package/src/shared/types/filetypes.ts +101 -0
- package/src/shared/types/findings.ts +7 -0
- package/src/shared/types/mod.ts +6 -0
- package/src/shared/types/permissions.ts +17 -0
- package/src/shared/types/references.ts +62 -0
- package/src/shared/types/risks.ts +72 -0
- package/src/shared/types/syntaxNode.ts +7 -0
- package/src/skillreader/cloudStorage/mod.ts +170 -0
- package/src/skillreader/factory.ts +71 -0
- package/src/skillreader/fs/git.ts +153 -0
- package/src/skillreader/fs/mod.ts +84 -0
- package/src/skillreader/github/base.ts +162 -0
- package/src/skillreader/github/githubApi.ts +40 -0
- package/src/skillreader/github/githubRaw.ts +24 -0
- package/src/skillreader/github/mod.ts +45 -0
- package/src/skillreader/github/utils.ts +40 -0
- package/src/skillreader/manifest.ts +67 -0
- package/src/skillreader/mod.ts +26 -0
- package/src/skillreader/types.ts +150 -0
- package/src/skillreader/utils/frontmatter-parser.ts +72 -0
- package/src/skillreader/utils/http-range.ts +38 -0
- package/src/skillreader/utils/mod.ts +12 -0
- package/esm/analyzer/astgrep/registry.d.ts +0 -18
- package/esm/analyzer/astgrep/registry.d.ts.map +0 -1
- package/esm/analyzer/astgrep/registry.js +0 -71
- package/esm/analyzer/config.d.ts +0 -27
- package/esm/analyzer/config.d.ts.map +0 -1
- package/esm/analyzer/steps/003-risks/output.d.ts +0 -3
- package/esm/analyzer/steps/003-risks/output.d.ts.map +0 -1
- package/esm/analyzer/steps/003-risks/output.js +0 -16
- package/esm/analyzer/treesiter/client.d.ts +0 -26
- package/esm/analyzer/treesiter/client.d.ts.map +0 -1
- package/script/analyzer/astgrep/registry.d.ts +0 -18
- package/script/analyzer/astgrep/registry.d.ts.map +0 -1
- package/script/analyzer/astgrep/registry.js +0 -109
- package/script/analyzer/config.d.ts +0 -27
- package/script/analyzer/config.d.ts.map +0 -1
- package/script/analyzer/steps/003-risks/output.d.ts +0 -3
- package/script/analyzer/steps/003-risks/output.d.ts.map +0 -1
- package/script/analyzer/steps/003-risks/output.js +0 -19
- package/script/analyzer/treesiter/client.d.ts +0 -26
- package/script/analyzer/treesiter/client.d.ts.map +0 -1
- package/script/analyzer/treesiter/client.js +0 -165
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
|
|
4
|
+
import { isPosixPathSeparator } from "./_util.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
|
+
* If `from` and `to` are the same, return an empty string.
|
|
12
|
+
*
|
|
13
|
+
* @example Usage
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { relative } from "@std/path/posix/relative";
|
|
16
|
+
* import { assertEquals } from "@std/assert";
|
|
17
|
+
*
|
|
18
|
+
* const path = relative("/data/orandea/test/aaa", "/data/orandea/impl/bbb");
|
|
19
|
+
* assertEquals(path, "../../impl/bbb");
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param from The path to start from.
|
|
23
|
+
* @param to The path to reach.
|
|
24
|
+
* @returns The relative path.
|
|
25
|
+
*/
|
|
26
|
+
export function relative(from: string, to: string): string {
|
|
27
|
+
assertArgs(from, to);
|
|
28
|
+
|
|
29
|
+
from = resolve(from);
|
|
30
|
+
to = resolve(to);
|
|
31
|
+
|
|
32
|
+
if (from === to) return "";
|
|
33
|
+
|
|
34
|
+
// Trim any leading backslashes
|
|
35
|
+
let fromStart = 1;
|
|
36
|
+
const fromEnd = from.length;
|
|
37
|
+
for (; fromStart < fromEnd; ++fromStart) {
|
|
38
|
+
if (!isPosixPathSeparator(from.charCodeAt(fromStart))) break;
|
|
39
|
+
}
|
|
40
|
+
const fromLen = fromEnd - fromStart;
|
|
41
|
+
|
|
42
|
+
// Trim any leading backslashes
|
|
43
|
+
let toStart = 1;
|
|
44
|
+
const toEnd = to.length;
|
|
45
|
+
for (; toStart < toEnd; ++toStart) {
|
|
46
|
+
if (!isPosixPathSeparator(to.charCodeAt(toStart))) break;
|
|
47
|
+
}
|
|
48
|
+
const toLen = toEnd - toStart;
|
|
49
|
+
|
|
50
|
+
// Compare paths to find the longest common path from root
|
|
51
|
+
const length = fromLen < toLen ? fromLen : toLen;
|
|
52
|
+
let lastCommonSep = -1;
|
|
53
|
+
let i = 0;
|
|
54
|
+
for (; i <= length; ++i) {
|
|
55
|
+
if (i === length) {
|
|
56
|
+
if (toLen > length) {
|
|
57
|
+
if (isPosixPathSeparator(to.charCodeAt(toStart + i))) {
|
|
58
|
+
// We get here if `from` is the exact base path for `to`.
|
|
59
|
+
// For example: from='/foo/bar'; to='/foo/bar/baz'
|
|
60
|
+
return to.slice(toStart + i + 1);
|
|
61
|
+
} else if (i === 0) {
|
|
62
|
+
// We get here if `from` is the root
|
|
63
|
+
// For example: from='/'; to='/foo'
|
|
64
|
+
return to.slice(toStart + i);
|
|
65
|
+
}
|
|
66
|
+
} else if (fromLen > length) {
|
|
67
|
+
if (isPosixPathSeparator(from.charCodeAt(fromStart + i))) {
|
|
68
|
+
// We get here if `to` is the exact base path for `from`.
|
|
69
|
+
// For example: from='/foo/bar/baz'; to='/foo/bar'
|
|
70
|
+
lastCommonSep = i;
|
|
71
|
+
} else if (i === 0) {
|
|
72
|
+
// We get here if `to` is the root.
|
|
73
|
+
// For example: from='/foo'; to='/'
|
|
74
|
+
lastCommonSep = 0;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
const fromCode = from.charCodeAt(fromStart + i);
|
|
80
|
+
const toCode = to.charCodeAt(toStart + i);
|
|
81
|
+
if (fromCode !== toCode) break;
|
|
82
|
+
else if (isPosixPathSeparator(fromCode)) lastCommonSep = i;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
let out = "";
|
|
86
|
+
// Generate the relative path based on the path difference between `to`
|
|
87
|
+
// and `from`
|
|
88
|
+
for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
|
|
89
|
+
if (i === fromEnd || isPosixPathSeparator(from.charCodeAt(i))) {
|
|
90
|
+
if (out.length === 0) out += "..";
|
|
91
|
+
else out += "/..";
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Lastly, append the rest of the destination (`to`) path that comes after
|
|
96
|
+
// the common path parts
|
|
97
|
+
if (out.length > 0) return out + to.slice(toStart + lastCommonSep);
|
|
98
|
+
else {
|
|
99
|
+
toStart += lastCommonSep;
|
|
100
|
+
if (isPosixPathSeparator(to.charCodeAt(toStart))) ++toStart;
|
|
101
|
+
return to.slice(toStart);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
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 { normalizeString } from "../_common/normalize_string.js";
|
|
7
|
+
import { assertPath } from "../_common/assert_path.js";
|
|
8
|
+
import { isPosixPathSeparator } from "./_util.js";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Resolves path segments into a `path`.
|
|
12
|
+
*
|
|
13
|
+
* @example Usage
|
|
14
|
+
* ```ts
|
|
15
|
+
* import { resolve } from "@std/path/posix/resolve";
|
|
16
|
+
* import { assertEquals } from "@std/assert";
|
|
17
|
+
*
|
|
18
|
+
* const path = resolve("/foo", "bar", "baz/asdf", "quux", "..");
|
|
19
|
+
* assertEquals(path, "/foo/bar/baz/asdf");
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param pathSegments The path segments to resolve.
|
|
23
|
+
* @returns The resolved path.
|
|
24
|
+
*/
|
|
25
|
+
export function resolve(...pathSegments: string[]): string {
|
|
26
|
+
let resolvedPath = "";
|
|
27
|
+
let resolvedAbsolute = false;
|
|
28
|
+
|
|
29
|
+
for (let i = pathSegments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
|
|
30
|
+
let path: string;
|
|
31
|
+
|
|
32
|
+
if (i >= 0) path = pathSegments[i]!;
|
|
33
|
+
else {
|
|
34
|
+
// deno-lint-ignore no-explicit-any
|
|
35
|
+
const { Deno } = dntShim.dntGlobalThis as any;
|
|
36
|
+
if (typeof Deno?.cwd !== "function") {
|
|
37
|
+
throw new TypeError(
|
|
38
|
+
"Resolved a relative path without a current working directory (CWD)",
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
path = Deno.cwd();
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
assertPath(path);
|
|
45
|
+
|
|
46
|
+
// Skip empty entries
|
|
47
|
+
if (path.length === 0) {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
resolvedPath = `${path}/${resolvedPath}`;
|
|
52
|
+
resolvedAbsolute = isPosixPathSeparator(path.charCodeAt(0));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// At this point the path should be resolved to a full absolute path, but
|
|
56
|
+
// handle relative paths to be safe (might happen when Deno.cwd() fails)
|
|
57
|
+
|
|
58
|
+
// Normalize the path
|
|
59
|
+
resolvedPath = normalizeString(
|
|
60
|
+
resolvedPath,
|
|
61
|
+
!resolvedAbsolute,
|
|
62
|
+
"/",
|
|
63
|
+
isPosixPathSeparator,
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
if (resolvedAbsolute) {
|
|
67
|
+
if (resolvedPath.length > 0) return `/${resolvedPath}`;
|
|
68
|
+
else return "/";
|
|
69
|
+
} else if (resolvedPath.length > 0) return resolvedPath;
|
|
70
|
+
else return ".";
|
|
71
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
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/posix/to-file-url";
|
|
13
|
+
* import { assertEquals } from "@std/assert";
|
|
14
|
+
*
|
|
15
|
+
* assertEquals(toFileUrl("/home/foo"), new URL("file:///home/foo"));
|
|
16
|
+
* assertEquals(toFileUrl("/home/foo bar"), new URL("file:///home/foo%20bar"));
|
|
17
|
+
* ```
|
|
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
|
+
|
|
27
|
+
const url = new URL("file:///");
|
|
28
|
+
url.pathname = encodeWhitespace(
|
|
29
|
+
path.replace(/%/g, "%25").replace(/\\/g, "%5C"),
|
|
30
|
+
);
|
|
31
|
+
return url;
|
|
32
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Converts a path to a namespaced path. This function returns the path as is on posix.
|
|
6
|
+
*
|
|
7
|
+
* @example Usage
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { toNamespacedPath } from "@std/path/posix/to-namespaced-path";
|
|
10
|
+
* import { assertEquals } from "@std/assert";
|
|
11
|
+
*
|
|
12
|
+
* assertEquals(toNamespacedPath("/home/foo"), "/home/foo");
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* @param path The path.
|
|
16
|
+
* @returns The namespaced path.
|
|
17
|
+
*/
|
|
18
|
+
export function toNamespacedPath(path: string): string {
|
|
19
|
+
// Non-op on posix systems
|
|
20
|
+
return path;
|
|
21
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
|
|
4
|
+
import { isWindows } from "../../internal/1.0.12/os.js";
|
|
5
|
+
import { relative as posixRelative } from "./posix/relative.js";
|
|
6
|
+
import { relative as windowsRelative } from "./windows/relative.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Return the relative path from `from` to `to` based on current working
|
|
10
|
+
* directory.
|
|
11
|
+
*
|
|
12
|
+
* @example Usage
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { relative } from "@std/path/relative";
|
|
15
|
+
* import { assertEquals } from "@std/assert";
|
|
16
|
+
*
|
|
17
|
+
* if (Deno.build.os === "windows") {
|
|
18
|
+
* const path = relative("C:\\foobar\\test\\aaa", "C:\\foobar\\impl\\bbb");
|
|
19
|
+
* assertEquals(path, "..\\..\\impl\\bbb");
|
|
20
|
+
* } else {
|
|
21
|
+
* const path = relative("/data/foobar/test/aaa", "/data/foobar/impl/bbb");
|
|
22
|
+
* assertEquals(path, "../../impl/bbb");
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @param from Path in current working directory.
|
|
27
|
+
* @param to Path in current working directory.
|
|
28
|
+
* @returns The relative path from `from` to `to`.
|
|
29
|
+
*/
|
|
30
|
+
export function relative(from: string, to: string): string {
|
|
31
|
+
return isWindows ? windowsRelative(from, to) : posixRelative(from, to);
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
|
|
4
|
+
import { isWindows } from "../../internal/1.0.12/os.js";
|
|
5
|
+
import { resolve as posixResolve } from "./posix/resolve.js";
|
|
6
|
+
import { resolve as windowsResolve } from "./windows/resolve.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Resolves path segments into a path.
|
|
10
|
+
*
|
|
11
|
+
* @example Usage
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { resolve } from "@std/path/resolve";
|
|
14
|
+
* import { assertEquals } from "@std/assert";
|
|
15
|
+
*
|
|
16
|
+
* if (Deno.build.os === "windows") {
|
|
17
|
+
* assertEquals(resolve("C:\\foo", "bar", "baz"), "C:\\foo\\bar\\baz");
|
|
18
|
+
* assertEquals(resolve("C:\\foo", "C:\\bar", "baz"), "C:\\bar\\baz");
|
|
19
|
+
* } else {
|
|
20
|
+
* assertEquals(resolve("/foo", "bar", "baz"), "/foo/bar/baz");
|
|
21
|
+
* assertEquals(resolve("/foo", "/bar", "baz"), "/bar/baz");
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @param pathSegments Path segments to process to path.
|
|
26
|
+
* @returns The resolved path.
|
|
27
|
+
*/
|
|
28
|
+
export function resolve(...pathSegments: string[]): string {
|
|
29
|
+
return isWindows
|
|
30
|
+
? windowsResolve(...pathSegments)
|
|
31
|
+
: posixResolve(...pathSegments);
|
|
32
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
|
|
4
|
+
import { isWindows } from "../../internal/1.0.12/os.js";
|
|
5
|
+
import { toFileUrl as posixToFileUrl } from "./posix/to_file_url.js";
|
|
6
|
+
import { toFileUrl as windowsToFileUrl } from "./windows/to_file_url.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Converts a path string to a file URL.
|
|
10
|
+
*
|
|
11
|
+
* @example Usage
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { toFileUrl } from "@std/path/to-file-url";
|
|
14
|
+
* import { assertEquals } from "@std/assert";
|
|
15
|
+
*
|
|
16
|
+
* if (Deno.build.os === "windows") {
|
|
17
|
+
* assertEquals(toFileUrl("\\home\\foo"), new URL("file:///home/foo"));
|
|
18
|
+
* assertEquals(toFileUrl("C:\\Users\\foo"), new URL("file:///C:/Users/foo"));
|
|
19
|
+
* assertEquals(toFileUrl("\\\\127.0.0.1\\home\\foo"), new URL("file://127.0.0.1/home/foo"));
|
|
20
|
+
* } else {
|
|
21
|
+
* assertEquals(toFileUrl("/home/foo"), new URL("file:///home/foo"));
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*
|
|
25
|
+
* @param path Path to convert to file URL.
|
|
26
|
+
* @returns The file URL equivalent to the path.
|
|
27
|
+
*/
|
|
28
|
+
export function toFileUrl(path: string): URL {
|
|
29
|
+
return isWindows ? windowsToFileUrl(path) : posixToFileUrl(path);
|
|
30
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
|
|
4
|
+
import { isWindows } from "../../internal/1.0.12/os.js";
|
|
5
|
+
import { toNamespacedPath as posixToNamespacedPath } from "./posix/to_namespaced_path.js";
|
|
6
|
+
import { toNamespacedPath as windowsToNamespacedPath } from "./windows/to_namespaced_path.js";
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Resolves path to a namespace path. This is a no-op on
|
|
10
|
+
* non-windows systems.
|
|
11
|
+
*
|
|
12
|
+
* @example Usage
|
|
13
|
+
* ```ts
|
|
14
|
+
* import { toNamespacedPath } from "@std/path/to-namespaced-path";
|
|
15
|
+
* import { assertEquals } from "@std/assert";
|
|
16
|
+
*
|
|
17
|
+
* if (Deno.build.os === "windows") {
|
|
18
|
+
* assertEquals(toNamespacedPath("C:\\foo\\bar"), "\\\\?\\C:\\foo\\bar");
|
|
19
|
+
* } else {
|
|
20
|
+
* assertEquals(toNamespacedPath("/foo/bar"), "/foo/bar");
|
|
21
|
+
* }
|
|
22
|
+
* ```
|
|
23
|
+
*
|
|
24
|
+
* @param path Path to resolve to namespace.
|
|
25
|
+
* @returns The resolved namespace path.
|
|
26
|
+
*/
|
|
27
|
+
export function toNamespacedPath(path: string): string {
|
|
28
|
+
return isWindows
|
|
29
|
+
? windowsToNamespacedPath(path)
|
|
30
|
+
: posixToNamespacedPath(path);
|
|
31
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* A parsed path object generated by path.parse() or consumed by path.format().
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { parse } from "@std/path";
|
|
10
|
+
*
|
|
11
|
+
* const parsedPathObj = parse("c:\\path\\dir\\index.html");
|
|
12
|
+
* parsedPathObj.root; // "c:\\"
|
|
13
|
+
* parsedPathObj.dir; // "c:\\path\\dir"
|
|
14
|
+
* parsedPathObj.base; // "index.html"
|
|
15
|
+
* parsedPathObj.ext; // ".html"
|
|
16
|
+
* parsedPathObj.name; // "index"
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export interface ParsedPath {
|
|
20
|
+
/**
|
|
21
|
+
* The root of the path such as '/' or 'c:\'
|
|
22
|
+
*/
|
|
23
|
+
root: string;
|
|
24
|
+
/**
|
|
25
|
+
* The full directory path of the parent such as '/home/user/dir' or 'c:\path\dir'
|
|
26
|
+
*/
|
|
27
|
+
dir: string;
|
|
28
|
+
/**
|
|
29
|
+
* The file name including extension (if any) such as 'index.html'
|
|
30
|
+
*/
|
|
31
|
+
base: string;
|
|
32
|
+
/**
|
|
33
|
+
* The file extension (if any) such as '.html'
|
|
34
|
+
*/
|
|
35
|
+
ext: string;
|
|
36
|
+
/**
|
|
37
|
+
* The file name without extension (if any) such as 'index'
|
|
38
|
+
*/
|
|
39
|
+
name: string;
|
|
40
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// Copyright the Browserify authors. MIT License.
|
|
3
|
+
// Ported from https://github.com/browserify/path-browserify/
|
|
4
|
+
// This module is browser compatible.
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
CHAR_BACKWARD_SLASH,
|
|
8
|
+
CHAR_FORWARD_SLASH,
|
|
9
|
+
CHAR_LOWERCASE_A,
|
|
10
|
+
CHAR_LOWERCASE_Z,
|
|
11
|
+
CHAR_UPPERCASE_A,
|
|
12
|
+
CHAR_UPPERCASE_Z,
|
|
13
|
+
} from "../_common/constants.js";
|
|
14
|
+
|
|
15
|
+
export function isPosixPathSeparator(code: number): boolean {
|
|
16
|
+
return code === CHAR_FORWARD_SLASH;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function isPathSeparator(code: number): boolean {
|
|
20
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function isWindowsDeviceRoot(code: number): boolean {
|
|
24
|
+
return (
|
|
25
|
+
(code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z) ||
|
|
26
|
+
(code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z)
|
|
27
|
+
);
|
|
28
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
assertArgs,
|
|
6
|
+
lastPathSegment,
|
|
7
|
+
stripSuffix,
|
|
8
|
+
} from "../_common/basename.js";
|
|
9
|
+
import { CHAR_COLON } from "../_common/constants.js";
|
|
10
|
+
import { stripTrailingSeparators } from "../_common/strip_trailing_separators.js";
|
|
11
|
+
import { isPathSeparator, isWindowsDeviceRoot } from "./_util.js";
|
|
12
|
+
import { fromFileUrl } from "./from_file_url.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Return the last portion of a `path`.
|
|
16
|
+
* Trailing directory separators are ignored, and optional suffix is removed.
|
|
17
|
+
*
|
|
18
|
+
* @example Usage
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { basename } from "@std/path/windows/basename";
|
|
21
|
+
* import { assertEquals } from "@std/assert";
|
|
22
|
+
*
|
|
23
|
+
* assertEquals(basename("C:\\user\\Documents\\"), "Documents");
|
|
24
|
+
* assertEquals(basename("C:\\user\\Documents\\image.png"), "image.png");
|
|
25
|
+
* assertEquals(basename("C:\\user\\Documents\\image.png", ".png"), "image");
|
|
26
|
+
* assertEquals(basename(new URL("file:///C:/user/Documents/image.png")), "image.png");
|
|
27
|
+
* assertEquals(basename(new URL("file:///C:/user/Documents/image.png"), ".png"), "image");
|
|
28
|
+
* ```
|
|
29
|
+
*
|
|
30
|
+
* @param path The path to extract the name from.
|
|
31
|
+
* @param suffix The suffix to remove from extracted name.
|
|
32
|
+
* @returns The extracted name.
|
|
33
|
+
*/
|
|
34
|
+
export function basename(path: string | URL, suffix = ""): string {
|
|
35
|
+
if (path instanceof URL) {
|
|
36
|
+
path = fromFileUrl(path);
|
|
37
|
+
}
|
|
38
|
+
assertArgs(path, suffix);
|
|
39
|
+
|
|
40
|
+
// Check for a drive letter prefix so as not to mistake the following
|
|
41
|
+
// path separator as an extra separator at the end of the path that can be
|
|
42
|
+
// disregarded
|
|
43
|
+
let start = 0;
|
|
44
|
+
if (path.length >= 2) {
|
|
45
|
+
const drive = path.charCodeAt(0);
|
|
46
|
+
if (isWindowsDeviceRoot(drive)) {
|
|
47
|
+
if (path.charCodeAt(1) === CHAR_COLON) start = 2;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const lastSegment = lastPathSegment(path, isPathSeparator, start);
|
|
52
|
+
const strippedSegment = stripTrailingSeparators(lastSegment, isPathSeparator);
|
|
53
|
+
return suffix ? stripSuffix(strippedSegment, suffix) : strippedSegment;
|
|
54
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The character used to separate entries in the PATH environment variable.
|
|
6
|
+
*/
|
|
7
|
+
export const DELIMITER = ";" as const;
|
|
8
|
+
/**
|
|
9
|
+
* The character used to separate components of a file path.
|
|
10
|
+
*/
|
|
11
|
+
export const SEPARATOR = "\\" as const;
|
|
12
|
+
/**
|
|
13
|
+
* A regular expression that matches one or more path separators.
|
|
14
|
+
*/
|
|
15
|
+
export const SEPARATOR_PATTERN = /[\\/]+/;
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// Copyright 2018-2025 the Deno authors. MIT license.
|
|
2
|
+
// This module is browser compatible.
|
|
3
|
+
|
|
4
|
+
import { assertArg } from "../_common/dirname.js";
|
|
5
|
+
import { CHAR_COLON } from "../_common/constants.js";
|
|
6
|
+
import { stripTrailingSeparators } from "../_common/strip_trailing_separators.js";
|
|
7
|
+
import {
|
|
8
|
+
isPathSeparator,
|
|
9
|
+
isPosixPathSeparator,
|
|
10
|
+
isWindowsDeviceRoot,
|
|
11
|
+
} from "./_util.js";
|
|
12
|
+
import { fromFileUrl } from "./from_file_url.js";
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Return the directory path of a `path`.
|
|
16
|
+
*
|
|
17
|
+
* @example Usage
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { dirname } from "@std/path/windows/dirname";
|
|
20
|
+
* import { assertEquals } from "@std/assert";
|
|
21
|
+
*
|
|
22
|
+
* assertEquals(dirname("C:\\foo\\bar\\baz.ext"), "C:\\foo\\bar");
|
|
23
|
+
* assertEquals(dirname(new URL("file:///C:/foo/bar/baz.ext")), "C:\\foo\\bar");
|
|
24
|
+
* ```
|
|
25
|
+
*
|
|
26
|
+
* @param path The path to get the directory from.
|
|
27
|
+
* @returns The directory path.
|
|
28
|
+
*/
|
|
29
|
+
export function dirname(path: string | URL): string {
|
|
30
|
+
if (path instanceof URL) {
|
|
31
|
+
path = fromFileUrl(path);
|
|
32
|
+
}
|
|
33
|
+
assertArg(path);
|
|
34
|
+
|
|
35
|
+
const len = path.length;
|
|
36
|
+
let rootEnd = -1;
|
|
37
|
+
let end = -1;
|
|
38
|
+
let matchedSlash = true;
|
|
39
|
+
let offset = 0;
|
|
40
|
+
const code = path.charCodeAt(0);
|
|
41
|
+
|
|
42
|
+
// Try to match a root
|
|
43
|
+
if (len > 1) {
|
|
44
|
+
if (isPathSeparator(code)) {
|
|
45
|
+
// Possible UNC root
|
|
46
|
+
|
|
47
|
+
rootEnd = offset = 1;
|
|
48
|
+
|
|
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
|
+
return path;
|
|
74
|
+
}
|
|
75
|
+
if (j !== last) {
|
|
76
|
+
// We matched a UNC root with leftovers
|
|
77
|
+
|
|
78
|
+
// Offset by 1 to include the separator after the UNC root to
|
|
79
|
+
// treat it as a "normal root" on top of a (UNC) root
|
|
80
|
+
rootEnd = offset = j + 1;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
} else if (isWindowsDeviceRoot(code)) {
|
|
86
|
+
// Possible device root
|
|
87
|
+
|
|
88
|
+
if (path.charCodeAt(1) === CHAR_COLON) {
|
|
89
|
+
rootEnd = offset = 2;
|
|
90
|
+
if (len > 2) {
|
|
91
|
+
if (isPathSeparator(path.charCodeAt(2))) rootEnd = offset = 3;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} else if (isPathSeparator(code)) {
|
|
96
|
+
// `path` contains just a path separator, exit early to avoid
|
|
97
|
+
// unnecessary work
|
|
98
|
+
return path;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
for (let i = len - 1; i >= offset; --i) {
|
|
102
|
+
if (isPathSeparator(path.charCodeAt(i))) {
|
|
103
|
+
if (!matchedSlash) {
|
|
104
|
+
end = i;
|
|
105
|
+
break;
|
|
106
|
+
}
|
|
107
|
+
} else {
|
|
108
|
+
// We saw the first non-path separator
|
|
109
|
+
matchedSlash = false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (end === -1) {
|
|
114
|
+
if (rootEnd === -1) return ".";
|
|
115
|
+
else end = rootEnd;
|
|
116
|
+
}
|
|
117
|
+
return stripTrailingSeparators(path.slice(0, end), isPosixPathSeparator);
|
|
118
|
+
}
|