@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,30 @@
|
|
|
1
|
+
// Ported from js-yaml v3.13.1:
|
|
2
|
+
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
|
3
|
+
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
|
4
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
5
|
+
|
|
6
|
+
import type { Type } from "../_type.js";
|
|
7
|
+
import { isPlainObject } from "../_utils.js";
|
|
8
|
+
|
|
9
|
+
function resolveYamlOmap(data: Record<string, unknown>[]): boolean {
|
|
10
|
+
const objectKeys = new Set();
|
|
11
|
+
for (const object of data) {
|
|
12
|
+
if (!isPlainObject(object)) return false;
|
|
13
|
+
const keys = Object.keys(object);
|
|
14
|
+
if (keys.length !== 1) return false;
|
|
15
|
+
for (const key of keys) {
|
|
16
|
+
if (objectKeys.has(key)) return false;
|
|
17
|
+
objectKeys.add(key);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const omap: Type<"sequence", Record<PropertyKey, unknown>[]> = {
|
|
24
|
+
tag: "tag:yaml.org,2002:omap",
|
|
25
|
+
kind: "sequence",
|
|
26
|
+
resolve: resolveYamlOmap,
|
|
27
|
+
construct(data) {
|
|
28
|
+
return data;
|
|
29
|
+
},
|
|
30
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Ported from js-yaml v3.13.1:
|
|
2
|
+
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
|
3
|
+
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
|
4
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
5
|
+
|
|
6
|
+
import type { Type } from "../_type.js";
|
|
7
|
+
import { isPlainObject } from "../_utils.js";
|
|
8
|
+
|
|
9
|
+
function resolveYamlPairs(data: unknown[][]): boolean {
|
|
10
|
+
if (data === null) return true;
|
|
11
|
+
return data.every((it) => isPlainObject(it) && Object.keys(it).length === 1);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const pairs: Type<"sequence"> = {
|
|
15
|
+
tag: "tag:yaml.org,2002:pairs",
|
|
16
|
+
construct(data: Record<string, unknown>[] | null): [string, unknown][] {
|
|
17
|
+
// Converts an array of objects into an array of key-value pairs.
|
|
18
|
+
return data?.flatMap(Object.entries) ?? [];
|
|
19
|
+
},
|
|
20
|
+
kind: "sequence",
|
|
21
|
+
resolve: resolveYamlPairs,
|
|
22
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Ported and adapted from js-yaml-js-types v1.0.0:
|
|
2
|
+
// https://github.com/nodeca/js-yaml-js-types/tree/ac537e7bbdd3c2cbbd9882ca3919c520c2dc022b
|
|
3
|
+
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
|
4
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
5
|
+
|
|
6
|
+
import type { Type } from "../_type.js";
|
|
7
|
+
|
|
8
|
+
const REGEXP = /^\/(?<regexp>[\s\S]+)\/(?<modifiers>[gismuy]*)$/;
|
|
9
|
+
|
|
10
|
+
export const regexp: Type<"scalar", RegExp> = {
|
|
11
|
+
tag: "tag:yaml.org,2002:js/regexp",
|
|
12
|
+
kind: "scalar",
|
|
13
|
+
resolve(data: string | null): boolean {
|
|
14
|
+
if (data === null || !data.length) return false;
|
|
15
|
+
|
|
16
|
+
if (data.charAt(0) === "/") {
|
|
17
|
+
// Ensure regex is properly terminated
|
|
18
|
+
const groups = data.match(REGEXP)?.groups;
|
|
19
|
+
if (!groups) return false;
|
|
20
|
+
// Check no duplicate modifiers
|
|
21
|
+
const modifiers = groups.modifiers ?? "";
|
|
22
|
+
if (new Set(modifiers).size < modifiers.length) return false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return true;
|
|
26
|
+
},
|
|
27
|
+
construct(data: string): RegExp {
|
|
28
|
+
const { regexp = data, modifiers = "" } = data.match(REGEXP)?.groups ?? {};
|
|
29
|
+
return new RegExp(regexp, modifiers);
|
|
30
|
+
},
|
|
31
|
+
predicate: (object: unknown): object is RegExp => object instanceof RegExp,
|
|
32
|
+
represent: (object: RegExp): string => object.toString(),
|
|
33
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Ported from js-yaml v3.13.1:
|
|
2
|
+
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
|
3
|
+
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
|
4
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
5
|
+
|
|
6
|
+
import type { Type } from "../_type.js";
|
|
7
|
+
|
|
8
|
+
export const seq: Type<"sequence", unknown[]> = {
|
|
9
|
+
tag: "tag:yaml.org,2002:seq",
|
|
10
|
+
kind: "sequence",
|
|
11
|
+
resolve: (): boolean => true,
|
|
12
|
+
construct: (data: unknown[] | null): unknown[] => data !== null ? data : [],
|
|
13
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Ported from js-yaml v3.13.1:
|
|
2
|
+
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
|
3
|
+
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
|
4
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
5
|
+
|
|
6
|
+
import type { Type } from "../_type.js";
|
|
7
|
+
|
|
8
|
+
export const set: Type<"mapping", Record<PropertyKey, unknown>> = {
|
|
9
|
+
tag: "tag:yaml.org,2002:set",
|
|
10
|
+
kind: "mapping",
|
|
11
|
+
construct: (data: Record<string, unknown>): Record<string, unknown> =>
|
|
12
|
+
data !== null ? data : {},
|
|
13
|
+
resolve: (data: Record<string, unknown>): boolean => {
|
|
14
|
+
if (data === null) return true;
|
|
15
|
+
return Object.values(data).every((it) => it === null);
|
|
16
|
+
},
|
|
17
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Ported from js-yaml v3.13.1:
|
|
2
|
+
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
|
3
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
4
|
+
|
|
5
|
+
import type { Type } from "../_type.js";
|
|
6
|
+
|
|
7
|
+
export const str: Type<"scalar", string> = {
|
|
8
|
+
tag: "tag:yaml.org,2002:str",
|
|
9
|
+
kind: "scalar",
|
|
10
|
+
resolve: (): boolean => true,
|
|
11
|
+
construct: (data: string | null): string => data !== null ? data : "",
|
|
12
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
// Ported from js-yaml v3.13.1:
|
|
2
|
+
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
|
3
|
+
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
|
4
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
5
|
+
|
|
6
|
+
import type { Type } from "../_type.js";
|
|
7
|
+
|
|
8
|
+
const YAML_DATE_REGEXP = new RegExp(
|
|
9
|
+
"^([0-9][0-9][0-9][0-9])" + // [1] year
|
|
10
|
+
"-([0-9][0-9])" + // [2] month
|
|
11
|
+
"-([0-9][0-9])$", // [3] day
|
|
12
|
+
);
|
|
13
|
+
|
|
14
|
+
const YAML_TIMESTAMP_REGEXP = new RegExp(
|
|
15
|
+
"^([0-9][0-9][0-9][0-9])" + // [1] year
|
|
16
|
+
"-([0-9][0-9]?)" + // [2] month
|
|
17
|
+
"-([0-9][0-9]?)" + // [3] day
|
|
18
|
+
"(?:[Tt]|[ \\t]+)" + // ...
|
|
19
|
+
"([0-9][0-9]?)" + // [4] hour
|
|
20
|
+
":([0-9][0-9])" + // [5] minute
|
|
21
|
+
":([0-9][0-9])" + // [6] second
|
|
22
|
+
"(?:\\.([0-9]*))?" + // [7] fraction
|
|
23
|
+
"(?:[ \\t]*(Z|([-+])([0-9][0-9]?)" + // [8] tz [9] tz_sign [10] tz_hour
|
|
24
|
+
"(?::([0-9][0-9]))?))?$", // [11] tz_minute
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
function resolveYamlTimestamp(data: string): boolean {
|
|
28
|
+
if (data === null) return false;
|
|
29
|
+
if (YAML_DATE_REGEXP.exec(data) !== null) return true;
|
|
30
|
+
if (YAML_TIMESTAMP_REGEXP.exec(data) !== null) return true;
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function constructYamlTimestamp(data: string): Date {
|
|
35
|
+
let match = YAML_DATE_REGEXP.exec(data);
|
|
36
|
+
if (match === null) match = YAML_TIMESTAMP_REGEXP.exec(data);
|
|
37
|
+
|
|
38
|
+
if (match === null) {
|
|
39
|
+
throw new Error("Cannot construct YAML timestamp: date resolve error");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// match: [1] year [2] month [3] day
|
|
43
|
+
|
|
44
|
+
const year = +match[1]!;
|
|
45
|
+
const month = +match[2]! - 1; // JS month starts with 0
|
|
46
|
+
const day = +match[3]!;
|
|
47
|
+
|
|
48
|
+
if (!match[4]) {
|
|
49
|
+
// no hour
|
|
50
|
+
return new Date(Date.UTC(year, month, day));
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// match: [4] hour [5] minute [6] second [7] fraction
|
|
54
|
+
|
|
55
|
+
const hour = +match[4];
|
|
56
|
+
const minute = +match[5]!;
|
|
57
|
+
const second = +match[6]!;
|
|
58
|
+
|
|
59
|
+
let fraction = 0;
|
|
60
|
+
if (match[7]) {
|
|
61
|
+
let partFraction = match[7].slice(0, 3);
|
|
62
|
+
while (partFraction.length < 3) {
|
|
63
|
+
// milli-seconds
|
|
64
|
+
partFraction += "0";
|
|
65
|
+
}
|
|
66
|
+
fraction = +partFraction;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// match: [8] tz [9] tz_sign [10] tz_hour [11] tz_minute
|
|
70
|
+
|
|
71
|
+
let delta = null;
|
|
72
|
+
if (match[9] && match[10]) {
|
|
73
|
+
const tzHour = +match[10];
|
|
74
|
+
const tzMinute = +(match[11] || 0);
|
|
75
|
+
delta = (tzHour * 60 + tzMinute) * 60000; // delta in milli-seconds
|
|
76
|
+
if (match[9] === "-") delta = -delta;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
const date = new Date(
|
|
80
|
+
Date.UTC(year, month, day, hour, minute, second, fraction),
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
if (delta) date.setTime(date.getTime() - delta);
|
|
84
|
+
|
|
85
|
+
return date;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function representYamlTimestamp(date: Date): string {
|
|
89
|
+
return date.toISOString();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const timestamp: Type<"scalar", Date> = {
|
|
93
|
+
tag: "tag:yaml.org,2002:timestamp",
|
|
94
|
+
construct: constructYamlTimestamp,
|
|
95
|
+
predicate(object): object is Date {
|
|
96
|
+
return object instanceof Date;
|
|
97
|
+
},
|
|
98
|
+
kind: "scalar",
|
|
99
|
+
represent: representYamlTimestamp,
|
|
100
|
+
resolve: resolveYamlTimestamp,
|
|
101
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// Ported and adapted from js-yaml-js-types v1.0.0:
|
|
2
|
+
// https://github.com/nodeca/js-yaml-js-types/tree/ac537e7bbdd3c2cbbd9882ca3919c520c2dc022b
|
|
3
|
+
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
|
4
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
5
|
+
|
|
6
|
+
import type { Type } from "../_type.js";
|
|
7
|
+
|
|
8
|
+
export const undefinedType: Type<"scalar", undefined> = {
|
|
9
|
+
tag: "tag:yaml.org,2002:js/undefined",
|
|
10
|
+
kind: "scalar",
|
|
11
|
+
resolve() {
|
|
12
|
+
return true;
|
|
13
|
+
},
|
|
14
|
+
construct() {
|
|
15
|
+
return undefined;
|
|
16
|
+
},
|
|
17
|
+
predicate(object) {
|
|
18
|
+
return typeof object === "undefined";
|
|
19
|
+
},
|
|
20
|
+
represent() {
|
|
21
|
+
return "";
|
|
22
|
+
},
|
|
23
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Ported from js-yaml v3.13.1:
|
|
2
|
+
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
|
3
|
+
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
|
4
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
5
|
+
// This module is browser compatible.
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* The kind of YAML node.
|
|
9
|
+
*/
|
|
10
|
+
export type KindType = "sequence" | "scalar" | "mapping";
|
|
11
|
+
/**
|
|
12
|
+
* The style variation for `styles` option of {@linkcode stringify}
|
|
13
|
+
*/
|
|
14
|
+
export type StyleVariant =
|
|
15
|
+
| "lowercase"
|
|
16
|
+
| "uppercase"
|
|
17
|
+
| "camelcase"
|
|
18
|
+
| "decimal"
|
|
19
|
+
| "binary"
|
|
20
|
+
| "octal"
|
|
21
|
+
| "hexadecimal";
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Function to convert data to a string for YAML serialization.
|
|
25
|
+
*/
|
|
26
|
+
export type RepresentFn<D> = (data: D, style?: StyleVariant) => string;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* A type definition for a YAML node.
|
|
30
|
+
*/
|
|
31
|
+
// deno-lint-ignore no-explicit-any
|
|
32
|
+
export interface Type<K extends KindType, D = any> {
|
|
33
|
+
/** Tag to identify the type */
|
|
34
|
+
tag: string;
|
|
35
|
+
/** Kind of type */
|
|
36
|
+
kind: K;
|
|
37
|
+
/** Cast the type. Used to stringify */
|
|
38
|
+
predicate?: (data: unknown) => data is D;
|
|
39
|
+
/** Function to represent data. Used to stringify */
|
|
40
|
+
represent?: RepresentFn<D> | Record<string, RepresentFn<D>>;
|
|
41
|
+
/** Default style for the type. Used to stringify */
|
|
42
|
+
defaultStyle?: StyleVariant;
|
|
43
|
+
/** Function to test whether data can be resolved by this type. Used to parse */
|
|
44
|
+
// deno-lint-ignore no-explicit-any
|
|
45
|
+
resolve: (data: any) => boolean;
|
|
46
|
+
/** Function to construct data from string. Used to parse */
|
|
47
|
+
// deno-lint-ignore no-explicit-any
|
|
48
|
+
construct: (data: any) => D;
|
|
49
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Ported from js-yaml v3.13.1:
|
|
2
|
+
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
|
3
|
+
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
|
4
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
5
|
+
|
|
6
|
+
export function isObject(value: unknown): value is Record<string, unknown> {
|
|
7
|
+
return value !== null && typeof value === "object";
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function isNegativeZero(i: number): boolean {
|
|
11
|
+
return i === 0 && Number.NEGATIVE_INFINITY === 1 / i;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function isPlainObject(object: unknown): object is object {
|
|
15
|
+
return Object.prototype.toString.call(object) === "[object Object]";
|
|
16
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
|
2
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
3
|
+
// This module is browser compatible.
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* {@linkcode parse} and {@linkcode stringify} for handling
|
|
7
|
+
* {@link https://yaml.org/ | YAML} encoded data.
|
|
8
|
+
*
|
|
9
|
+
* Ported from
|
|
10
|
+
* {@link https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da | js-yaml v3.13.1}.
|
|
11
|
+
*
|
|
12
|
+
* Use {@linkcode parseAll} for parsing multiple documents in a single YAML
|
|
13
|
+
* string.
|
|
14
|
+
*
|
|
15
|
+
* This package generally supports
|
|
16
|
+
* {@link https://yaml.org/spec/1.2.2/ | YAML 1.2.x} (latest) and some
|
|
17
|
+
* {@link https://yaml.org/spec/1.1/current.html | YAML 1.1} features that are
|
|
18
|
+
* commonly used in the wild.
|
|
19
|
+
*
|
|
20
|
+
* Supported YAML 1.1 features include:
|
|
21
|
+
* - {@link https://yaml.org/type/merge.html | Merge} type (`<<` symbol)
|
|
22
|
+
*
|
|
23
|
+
* Unsupported YAML 1.1 features include:
|
|
24
|
+
* - Yes, No, On, Off literals for bool type
|
|
25
|
+
* - Sexagesimal numbers (e.g. `3:25:45`)
|
|
26
|
+
*
|
|
27
|
+
* ```ts
|
|
28
|
+
* import { parse, stringify } from "@std/yaml";
|
|
29
|
+
* import { assertEquals } from "@std/assert";
|
|
30
|
+
*
|
|
31
|
+
* const data = parse(`
|
|
32
|
+
* foo: bar
|
|
33
|
+
* baz:
|
|
34
|
+
* - qux
|
|
35
|
+
* - quux
|
|
36
|
+
* `);
|
|
37
|
+
* assertEquals(data, { foo: "bar", baz: [ "qux", "quux" ] });
|
|
38
|
+
*
|
|
39
|
+
* const yaml = stringify({ foo: "bar", baz: ["qux", "quux"] });
|
|
40
|
+
* assertEquals(yaml, `foo: bar
|
|
41
|
+
* baz:
|
|
42
|
+
* - qux
|
|
43
|
+
* - quux
|
|
44
|
+
* `);
|
|
45
|
+
* ```
|
|
46
|
+
*
|
|
47
|
+
* ## Limitations
|
|
48
|
+
* - `binary` type is currently not stable.
|
|
49
|
+
*
|
|
50
|
+
* @module
|
|
51
|
+
*/
|
|
52
|
+
|
|
53
|
+
export * from "./parse.js";
|
|
54
|
+
export * from "./stringify.js";
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// Ported from js-yaml v3.13.1:
|
|
2
|
+
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
|
3
|
+
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
|
4
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
5
|
+
// This module is browser compatible.
|
|
6
|
+
|
|
7
|
+
import { isEOL } from "./_chars.js";
|
|
8
|
+
import { LoaderState } from "./_loader_state.js";
|
|
9
|
+
import { SCHEMA_MAP, type SchemaType } from "./_schema.js";
|
|
10
|
+
|
|
11
|
+
export type { SchemaType };
|
|
12
|
+
|
|
13
|
+
/** Options for {@linkcode parse}. */
|
|
14
|
+
export interface ParseOptions {
|
|
15
|
+
/**
|
|
16
|
+
* Name of the schema to use.
|
|
17
|
+
*
|
|
18
|
+
* @default {"default"}
|
|
19
|
+
*/
|
|
20
|
+
schema?: SchemaType;
|
|
21
|
+
/**
|
|
22
|
+
* If `true`, duplicate keys will overwrite previous values. Otherwise,
|
|
23
|
+
* duplicate keys will throw a {@linkcode SyntaxError}.
|
|
24
|
+
*
|
|
25
|
+
* @default {false}
|
|
26
|
+
*/
|
|
27
|
+
allowDuplicateKeys?: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* If defined, a function to call on warning messages taking an
|
|
30
|
+
* {@linkcode Error} as its only argument.
|
|
31
|
+
*/
|
|
32
|
+
onWarning?(error: Error): void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function sanitizeInput(input: string) {
|
|
36
|
+
input = String(input);
|
|
37
|
+
|
|
38
|
+
if (input.length > 0) {
|
|
39
|
+
// Add trailing `\n` if not exists
|
|
40
|
+
if (!isEOL(input.charCodeAt(input.length - 1))) input += "\n";
|
|
41
|
+
|
|
42
|
+
// Strip BOM
|
|
43
|
+
if (input.charCodeAt(0) === 0xfeff) input = input.slice(1);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Use 0 as string terminator. That significantly simplifies bounds check.
|
|
47
|
+
input += "\0";
|
|
48
|
+
|
|
49
|
+
return input;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Parse and return a YAML string as a parsed YAML document object.
|
|
54
|
+
*
|
|
55
|
+
* Note: This does not support functions. Untrusted data is safe to parse.
|
|
56
|
+
*
|
|
57
|
+
* @example Usage
|
|
58
|
+
* ```ts
|
|
59
|
+
* import { parse } from "@std/yaml/parse";
|
|
60
|
+
* import { assertEquals } from "@std/assert";
|
|
61
|
+
*
|
|
62
|
+
* const data = parse(`
|
|
63
|
+
* id: 1
|
|
64
|
+
* name: Alice
|
|
65
|
+
* `);
|
|
66
|
+
*
|
|
67
|
+
* assertEquals(data, { id: 1, name: "Alice" });
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @throws {SyntaxError} Throws error on invalid YAML.
|
|
71
|
+
* @param content YAML string to parse.
|
|
72
|
+
* @param options Parsing options.
|
|
73
|
+
* @returns Parsed document.
|
|
74
|
+
*/
|
|
75
|
+
export function parse(
|
|
76
|
+
content: string,
|
|
77
|
+
options: ParseOptions = {},
|
|
78
|
+
): unknown {
|
|
79
|
+
content = sanitizeInput(content);
|
|
80
|
+
const state = new LoaderState(content, {
|
|
81
|
+
...options,
|
|
82
|
+
schema: SCHEMA_MAP.get(options.schema!)!,
|
|
83
|
+
});
|
|
84
|
+
const documentGenerator = state.readDocuments();
|
|
85
|
+
const document = documentGenerator.next().value;
|
|
86
|
+
if (!documentGenerator.next().done) {
|
|
87
|
+
throw new SyntaxError(
|
|
88
|
+
"Found more than 1 document in the stream: expected a single document",
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
return document ?? null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Same as {@linkcode parse}, but understands multi-document YAML sources, and
|
|
96
|
+
* returns multiple parsed YAML document objects.
|
|
97
|
+
*
|
|
98
|
+
* @example Usage
|
|
99
|
+
* ```ts
|
|
100
|
+
* import { parseAll } from "@std/yaml/parse";
|
|
101
|
+
* import { assertEquals } from "@std/assert";
|
|
102
|
+
*
|
|
103
|
+
* const data = parseAll(`
|
|
104
|
+
* ---
|
|
105
|
+
* id: 1
|
|
106
|
+
* name: Alice
|
|
107
|
+
* ---
|
|
108
|
+
* id: 2
|
|
109
|
+
* name: Bob
|
|
110
|
+
* ---
|
|
111
|
+
* id: 3
|
|
112
|
+
* name: Eve
|
|
113
|
+
* `);
|
|
114
|
+
* assertEquals(data, [ { id: 1, name: "Alice" }, { id: 2, name: "Bob" }, { id: 3, name: "Eve" }]);
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* @param content YAML string to parse.
|
|
118
|
+
* @param options Parsing options.
|
|
119
|
+
* @returns Array of parsed documents.
|
|
120
|
+
*/
|
|
121
|
+
export function parseAll(content: string, options: ParseOptions = {}): unknown {
|
|
122
|
+
content = sanitizeInput(content);
|
|
123
|
+
const state = new LoaderState(content, {
|
|
124
|
+
...options,
|
|
125
|
+
schema: SCHEMA_MAP.get(options.schema!)!,
|
|
126
|
+
});
|
|
127
|
+
return [...state.readDocuments()];
|
|
128
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
// Ported from js-yaml v3.13.1:
|
|
2
|
+
// https://github.com/nodeca/js-yaml/commit/665aadda42349dcae869f12040d9b10ef18d12da
|
|
3
|
+
// Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license.
|
|
4
|
+
// Copyright 2018-2026 the Deno authors. MIT license.
|
|
5
|
+
// This module is browser compatible.
|
|
6
|
+
|
|
7
|
+
import { DumperState } from "./_dumper_state.js";
|
|
8
|
+
import { SCHEMA_MAP, type SchemaType } from "./_schema.js";
|
|
9
|
+
import type { StyleVariant } from "./_type.js";
|
|
10
|
+
|
|
11
|
+
export type { SchemaType, StyleVariant };
|
|
12
|
+
|
|
13
|
+
/** Options for {@linkcode stringify}. */
|
|
14
|
+
export type StringifyOptions = {
|
|
15
|
+
/**
|
|
16
|
+
* Indentation width to use (in spaces).
|
|
17
|
+
*
|
|
18
|
+
* @default {2}
|
|
19
|
+
*/
|
|
20
|
+
indent?: number;
|
|
21
|
+
/**
|
|
22
|
+
* When true, adds an indentation level to array elements.
|
|
23
|
+
*
|
|
24
|
+
* @default {true}
|
|
25
|
+
*/
|
|
26
|
+
arrayIndent?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Do not throw on invalid types (like function in the safe schema) and skip
|
|
29
|
+
* pairs and single values with such types.
|
|
30
|
+
*
|
|
31
|
+
* @default {false}
|
|
32
|
+
*/
|
|
33
|
+
skipInvalid?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Specifies level of nesting, when to switch from block to flow style for
|
|
36
|
+
* collections. `-1` means block style everywhere.
|
|
37
|
+
*
|
|
38
|
+
* @default {-1}
|
|
39
|
+
*/
|
|
40
|
+
flowLevel?: number;
|
|
41
|
+
/** Each tag may have own set of styles. - "tag" => "style" map. */
|
|
42
|
+
styles?: Record<string, StyleVariant>;
|
|
43
|
+
/**
|
|
44
|
+
* Name of the schema to use.
|
|
45
|
+
*
|
|
46
|
+
* @default {"default"}
|
|
47
|
+
*/
|
|
48
|
+
schema?: SchemaType;
|
|
49
|
+
/**
|
|
50
|
+
* If true, sort keys when dumping YAML in ascending, ASCII character order.
|
|
51
|
+
* If a function, use the function to sort the keys.
|
|
52
|
+
* If a function is specified, the function must return a negative value
|
|
53
|
+
* if first argument is less than second argument, zero if they're equal
|
|
54
|
+
* and a positive value otherwise.
|
|
55
|
+
*
|
|
56
|
+
* @default {false}
|
|
57
|
+
*/
|
|
58
|
+
sortKeys?: boolean | ((a: string, b: string) => number);
|
|
59
|
+
/**
|
|
60
|
+
* Set max line width.
|
|
61
|
+
*
|
|
62
|
+
* @default {80}
|
|
63
|
+
*/
|
|
64
|
+
lineWidth?: number;
|
|
65
|
+
/**
|
|
66
|
+
* If false, don't convert duplicate objects into references.
|
|
67
|
+
*
|
|
68
|
+
* @default {true}
|
|
69
|
+
*/
|
|
70
|
+
useAnchors?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* If false don't try to be compatible with older yaml versions.
|
|
73
|
+
* Currently: don't quote "yes", "no" and so on,
|
|
74
|
+
* as required for YAML 1.1.
|
|
75
|
+
*
|
|
76
|
+
* @default {true}
|
|
77
|
+
*/
|
|
78
|
+
compatMode?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* If true flow sequences will be condensed, omitting the
|
|
81
|
+
* space between `key: value` or `a, b`. Eg. `'[a,b]'` or `{a:{b:c}}`.
|
|
82
|
+
* Can be useful when using yaml for pretty URL query params
|
|
83
|
+
* as spaces are %-encoded.
|
|
84
|
+
*
|
|
85
|
+
* @default {false}
|
|
86
|
+
*/
|
|
87
|
+
condenseFlow?: boolean;
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Converts a JavaScript object or value to a YAML document string.
|
|
92
|
+
*
|
|
93
|
+
* @example Usage
|
|
94
|
+
* ```ts
|
|
95
|
+
* import { stringify } from "@std/yaml/stringify";
|
|
96
|
+
* import { assertEquals } from "@std/assert";
|
|
97
|
+
*
|
|
98
|
+
* const data = { id: 1, name: "Alice" };
|
|
99
|
+
* const yaml = stringify(data);
|
|
100
|
+
*
|
|
101
|
+
* assertEquals(yaml, "id: 1\nname: Alice\n");
|
|
102
|
+
* ```
|
|
103
|
+
*
|
|
104
|
+
* @throws {TypeError} If `data` contains invalid types.
|
|
105
|
+
* @param data The data to serialize.
|
|
106
|
+
* @param options The options for serialization.
|
|
107
|
+
* @returns A YAML string.
|
|
108
|
+
*/
|
|
109
|
+
export function stringify(
|
|
110
|
+
data: unknown,
|
|
111
|
+
options: StringifyOptions = {},
|
|
112
|
+
): string {
|
|
113
|
+
const state = new DumperState({
|
|
114
|
+
...options,
|
|
115
|
+
schema: SCHEMA_MAP.get(options.schema!)!,
|
|
116
|
+
});
|
|
117
|
+
return state.stringify(data);
|
|
118
|
+
}
|