ast-grep-cli 0.45.2__tar.gz → 0.50.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/Cargo.lock +125 -57
  2. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/Cargo.toml +8 -8
  3. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/PKG-INFO +1 -1
  4. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/Cargo.toml +3 -1
  5. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/config.rs +61 -8
  6. ast_grep_cli-0.50.0/crates/cli/src/custom_language.rs +241 -0
  7. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/lib.rs +36 -16
  8. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/new.rs +9 -2
  9. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/scan.rs +13 -2
  10. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/utils/args.rs +9 -1
  11. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/utils/debug_query.rs +9 -1
  12. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/utils/error_context.rs +7 -1
  13. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/utils/rule_overwrite.rs +28 -5
  14. ast_grep_cli-0.50.0/crates/cli/tests/custom_language_policy_test.rs +231 -0
  15. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/tests/run_test.rs +39 -5
  16. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/tests/scan_test.rs +128 -0
  17. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/combined.rs +40 -1
  18. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/rule_config.rs +20 -3
  19. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/replacer/template.rs +29 -0
  20. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/tree_sitter/mod.rs +1 -1
  21. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/Cargo.toml +2 -0
  22. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/lib.rs +12 -1
  23. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/parsers.rs +3 -0
  24. ast_grep_cli-0.50.0/crates/language/src/zig.rs +84 -0
  25. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/default_rule.rs +2 -0
  26. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/default_rules/c.yml +4 -0
  27. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/default_rules/cpp.yml +2 -0
  28. ast_grep_cli-0.50.0/crates/outline/src/default_rules/java.yml +229 -0
  29. ast_grep_cli-0.50.0/crates/outline/src/default_rules/markdown.yml +31 -0
  30. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/extractor.rs +111 -4
  31. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/tests/c_family_outline_rules.rs +12 -2
  32. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/tests/default_outline_rules.rs +1 -0
  33. ast_grep_cli-0.50.0/crates/outline/tests/fixtures/markdown_headings.md +18 -0
  34. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/tests/javascript_outline_rules.rs +19 -0
  35. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/tests/jvm_swift_outline_rules.rs +181 -0
  36. ast_grep_cli-0.50.0/crates/outline/tests/markdown_outline_rules.rs +24 -0
  37. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/tests/typescript_outline_rules.rs +19 -0
  38. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/pyproject.toml +1 -1
  39. ast_grep_cli-0.45.2/crates/outline/src/default_rules/java.yml +0 -135
  40. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/LICENSE +0 -0
  41. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/README.md +0 -0
  42. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/README.md +0 -0
  43. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/bin/alias.rs +0 -0
  44. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/completions.rs +0 -0
  45. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/lang/injection.rs +0 -0
  46. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/lang/lang_globs.rs +0 -0
  47. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/lang/mod.rs +0 -0
  48. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/lsp.rs +0 -0
  49. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/main.rs +0 -0
  50. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/outline/extract.rs +0 -0
  51. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/outline/options.rs +0 -0
  52. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/outline/output/tests.rs +0 -0
  53. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/outline/output.rs +0 -0
  54. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/outline.rs +0 -0
  55. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/print/cloud_print.rs +0 -0
  56. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/print/colored_print/markdown.rs +0 -0
  57. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/print/colored_print/match_merger.rs +0 -0
  58. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/print/colored_print/styles.rs +0 -0
  59. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/print/colored_print/test.rs +0 -0
  60. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/print/colored_print.rs +0 -0
  61. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/print/file_name_printer.rs +0 -0
  62. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/print/interactive_print.rs +0 -0
  63. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/print/json_print.rs +0 -0
  64. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/print/mod.rs +0 -0
  65. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/run.rs +0 -0
  66. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/utils/inspect.rs +0 -0
  67. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/utils/mod.rs +0 -0
  68. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/utils/print_diff.rs +0 -0
  69. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/utils/worker.rs +0 -0
  70. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/verify/case_result.rs +0 -0
  71. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/verify/find_file.rs +0 -0
  72. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/verify/reporter.rs +0 -0
  73. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/verify/snapshot.rs +0 -0
  74. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/verify/test_case.rs +0 -0
  75. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/src/verify.rs +0 -0
  76. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/tests/common/mod.rs +0 -0
  77. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/tests/help_test.rs +0 -0
  78. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/cli/tests/verify_test.rs +0 -0
  79. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/Cargo.toml +0 -0
  80. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/check_var.rs +0 -0
  81. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/fixer.rs +0 -0
  82. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/label.rs +0 -0
  83. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/lib.rs +0 -0
  84. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/maybe.rs +0 -0
  85. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/rewriter.rs +0 -0
  86. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/rule/deserialize_env.rs +0 -0
  87. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/rule/mod.rs +0 -0
  88. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/rule/nth_child.rs +0 -0
  89. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/rule/parameterized_util.rs +0 -0
  90. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/rule/range.rs +0 -0
  91. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/rule/referent_rule.rs +0 -0
  92. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/rule/relational_rule.rs +0 -0
  93. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/rule/selector.rs +0 -0
  94. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/rule/stop_by.rs +0 -0
  95. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/rule_collection.rs +0 -0
  96. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/rule_core.rs +0 -0
  97. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/transform/mod.rs +0 -0
  98. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/transform/parse.rs +0 -0
  99. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/transform/rewrite.rs +0 -0
  100. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/transform/string_case.rs +0 -0
  101. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/config/src/transform/trans.rs +0 -0
  102. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/Cargo.toml +0 -0
  103. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/language.rs +0 -0
  104. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/lib.rs +0 -0
  105. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/match_tree/match_node.rs +0 -0
  106. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/match_tree/mod.rs +0 -0
  107. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/match_tree/strictness.rs +0 -0
  108. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/matcher/kind.rs +0 -0
  109. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/matcher/node_match.rs +0 -0
  110. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/matcher/pattern.rs +0 -0
  111. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/matcher/text.rs +0 -0
  112. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/matcher.rs +0 -0
  113. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/meta_var.rs +0 -0
  114. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/node.rs +0 -0
  115. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/ops.rs +0 -0
  116. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/pinned.rs +0 -0
  117. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/replacer/indent.rs +0 -0
  118. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/replacer/structural.rs +0 -0
  119. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/replacer.rs +0 -0
  120. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/source.rs +0 -0
  121. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/core/src/tree_sitter/traversal.rs +0 -0
  122. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/dynamic/Cargo.toml +0 -0
  123. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/dynamic/src/custom_lang.rs +0 -0
  124. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/dynamic/src/lib.rs +0 -0
  125. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/bash.rs +0 -0
  126. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/cpp.rs +0 -0
  127. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/csharp.rs +0 -0
  128. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/css.rs +0 -0
  129. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/dart.rs +0 -0
  130. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/elixir.rs +0 -0
  131. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/go.rs +0 -0
  132. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/haskell.rs +0 -0
  133. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/hcl.rs +0 -0
  134. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/html.rs +0 -0
  135. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/json.rs +0 -0
  136. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/kotlin.rs +0 -0
  137. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/lua.rs +0 -0
  138. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/markdown.rs +0 -0
  139. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/nix.rs +0 -0
  140. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/php.rs +0 -0
  141. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/python.rs +0 -0
  142. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/ruby.rs +0 -0
  143. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/rust.rs +0 -0
  144. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/scala.rs +0 -0
  145. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/solidity.rs +0 -0
  146. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/swift.rs +0 -0
  147. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/language/src/yaml.rs +0 -0
  148. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/lsp/Cargo.toml +0 -0
  149. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/lsp/src/lib.rs +0 -0
  150. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/lsp/src/utils.rs +0 -0
  151. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/lsp/tests/basic.rs +0 -0
  152. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/Cargo.toml +0 -0
  153. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/combined_extractor.rs +0 -0
  154. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/default_rules/csharp.yml +0 -0
  155. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/default_rules/go.yml +0 -0
  156. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/default_rules/javascript.yml +0 -0
  157. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/default_rules/kotlin.yml +0 -0
  158. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/default_rules/php.yml +0 -0
  159. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/default_rules/python.yml +0 -0
  160. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/default_rules/ruby.yml +0 -0
  161. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/default_rules/rust.yml +0 -0
  162. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/default_rules/swift.yml +0 -0
  163. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/default_rules/typescript.yml +0 -0
  164. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/lib.rs +0 -0
  165. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/model.rs +0 -0
  166. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/src/options.rs +0 -0
  167. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/tests/common/mod.rs +0 -0
  168. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/tests/python_go_outline_rules.rs +0 -0
  169. {ast_grep_cli-0.45.2 → ast_grep_cli-0.50.0}/crates/outline/tests/ruby_php_outline_rules.rs +0 -0
@@ -103,7 +103,7 @@ dependencies = [
103
103
 
104
104
  [[package]]
105
105
  name = "ast-grep"
106
- version = "0.45.2"
106
+ version = "0.50.0"
107
107
  dependencies = [
108
108
  "ansi_term",
109
109
  "anyhow",
@@ -119,6 +119,8 @@ dependencies = [
119
119
  "codespan-reporting",
120
120
  "crossterm",
121
121
  "dashmap",
122
+ "directories",
123
+ "fs2",
122
124
  "ignore",
123
125
  "inquire",
124
126
  "predicates",
@@ -139,7 +141,7 @@ dependencies = [
139
141
 
140
142
  [[package]]
141
143
  name = "ast-grep-config"
142
- version = "0.45.2"
144
+ version = "0.50.0"
143
145
  dependencies = [
144
146
  "ast-grep-core",
145
147
  "bit-set",
@@ -149,24 +151,24 @@ dependencies = [
149
151
  "serde",
150
152
  "serde_regex",
151
153
  "serde_yaml",
152
- "thiserror 2.0.20",
154
+ "thiserror 2.0.21",
153
155
  "tree-sitter-typescript",
154
156
  ]
155
157
 
156
158
  [[package]]
157
159
  name = "ast-grep-core"
158
- version = "0.45.2"
160
+ version = "0.50.0"
159
161
  dependencies = [
160
162
  "bit-set",
161
163
  "regex",
162
- "thiserror 2.0.20",
164
+ "thiserror 2.0.21",
163
165
  "tree-sitter",
164
166
  "tree-sitter-typescript",
165
167
  ]
166
168
 
167
169
  [[package]]
168
170
  name = "ast-grep-dynamic"
169
- version = "0.45.2"
171
+ version = "0.50.0"
170
172
  dependencies = [
171
173
  "ast-grep-core",
172
174
  "ignore",
@@ -174,13 +176,13 @@ dependencies = [
174
176
  "serde",
175
177
  "serde_yaml",
176
178
  "target-triple",
177
- "thiserror 2.0.20",
179
+ "thiserror 2.0.21",
178
180
  "tree-sitter",
179
181
  ]
180
182
 
181
183
  [[package]]
182
184
  name = "ast-grep-language"
183
- version = "0.45.2"
185
+ version = "0.50.0"
184
186
  dependencies = [
185
187
  "ast-grep-core",
186
188
  "ignore",
@@ -213,11 +215,12 @@ dependencies = [
213
215
  "tree-sitter-swift",
214
216
  "tree-sitter-typescript",
215
217
  "tree-sitter-yaml",
218
+ "tree-sitter-zig",
216
219
  ]
217
220
 
218
221
  [[package]]
219
222
  name = "ast-grep-lsp"
220
- version = "0.45.2"
223
+ version = "0.50.0"
221
224
  dependencies = [
222
225
  "anyhow",
223
226
  "ast-grep-config",
@@ -235,7 +238,7 @@ dependencies = [
235
238
 
236
239
  [[package]]
237
240
  name = "ast-grep-napi"
238
- version = "0.45.2"
241
+ version = "0.50.0"
239
242
  dependencies = [
240
243
  "ast-grep-config",
241
244
  "ast-grep-core",
@@ -251,7 +254,7 @@ dependencies = [
251
254
 
252
255
  [[package]]
253
256
  name = "ast-grep-outline"
254
- version = "0.45.2"
257
+ version = "0.50.0"
255
258
  dependencies = [
256
259
  "ast-grep-config",
257
260
  "ast-grep-core",
@@ -260,12 +263,12 @@ dependencies = [
260
263
  "serde",
261
264
  "serde_json",
262
265
  "serde_yaml",
263
- "thiserror 2.0.20",
266
+ "thiserror 2.0.21",
264
267
  ]
265
268
 
266
269
  [[package]]
267
270
  name = "ast-grep-py"
268
- version = "0.45.2"
271
+ version = "0.50.0"
269
272
  dependencies = [
270
273
  "anyhow",
271
274
  "ast-grep-config",
@@ -402,9 +405,9 @@ checksum = "f079e83a288787bcd14a6aea84cee5c87a67c5a3e660c30f557a3d24761b3527"
402
405
 
403
406
  [[package]]
404
407
  name = "clap"
405
- version = "4.6.6"
408
+ version = "4.6.7"
406
409
  source = "registry+https://github.com/rust-lang/crates.io-index"
407
- checksum = "473c7e07f409a8d772161724aa8db6a765a2532a70f9667eeb7b49d3d02fbdca"
410
+ checksum = "aa8876b300ab35ba921adea3dfd70157a46249b33f95c9084ae5709785478946"
408
411
  dependencies = [
409
412
  "clap_builder",
410
413
  "clap_derive",
@@ -412,9 +415,9 @@ dependencies = [
412
415
 
413
416
  [[package]]
414
417
  name = "clap_builder"
415
- version = "4.6.6"
418
+ version = "4.6.7"
416
419
  source = "registry+https://github.com/rust-lang/crates.io-index"
417
- checksum = "7b48fea5a88e9ae728a2dcbedbfc0e730f7d60da42e1cb049a83c9fb8b789889"
420
+ checksum = "ec0797fb7aeb1406c84efac526901f7ec3ead2124f946b494e72879d4b54704d"
418
421
  dependencies = [
419
422
  "anstream",
420
423
  "anstyle",
@@ -424,18 +427,18 @@ dependencies = [
424
427
 
425
428
  [[package]]
426
429
  name = "clap_complete"
427
- version = "4.6.9"
430
+ version = "4.6.11"
428
431
  source = "registry+https://github.com/rust-lang/crates.io-index"
429
- checksum = "3be2ad0423bdbbb0e25bc89add796f3559706d4a95e1bc98e4d9662a957b6a19"
432
+ checksum = "037e2a1a92236d0aff7e845093f64661d6df4c02c9fcc61a60e9e1d736fa392f"
430
433
  dependencies = [
431
434
  "clap",
432
435
  ]
433
436
 
434
437
  [[package]]
435
438
  name = "clap_derive"
436
- version = "4.6.4"
439
+ version = "4.6.7"
437
440
  source = "registry+https://github.com/rust-lang/crates.io-index"
438
- checksum = "d012d2b9d65aca7f18f4d9878a045bc17899bba951561ba5ec3c2ba1eed9a061"
441
+ checksum = "f9c751b79415d4e559e3d1fcf128e09e720eb673a06d26cf6f392d37d75b66e0"
439
442
  dependencies = [
440
443
  "heck",
441
444
  "proc-macro2",
@@ -477,9 +480,9 @@ dependencies = [
477
480
 
478
481
  [[package]]
479
482
  name = "convert_case"
480
- version = "0.11.0"
483
+ version = "0.12.0"
481
484
  source = "registry+https://github.com/rust-lang/crates.io-index"
482
- checksum = "affbf0190ed2caf063e3def54ff444b449371d55c58e513a95ab98eca50adb49"
485
+ checksum = "1af709f1f33454bf52eadfc8c78b3b9ef9cb26fb54d16dc9cd9a7299f899fd1b"
483
486
  dependencies = [
484
487
  "unicode-segmentation",
485
488
  ]
@@ -650,6 +653,27 @@ version = "0.4.0"
650
653
  source = "registry+https://github.com/rust-lang/crates.io-index"
651
654
  checksum = "6184e33543162437515c2e2b48714794e37845ec9851711914eec9d308f6ebe8"
652
655
 
656
+ [[package]]
657
+ name = "directories"
658
+ version = "6.0.0"
659
+ source = "registry+https://github.com/rust-lang/crates.io-index"
660
+ checksum = "16f5094c54661b38d03bd7e50df373292118db60b585c08a411c6d840017fe7d"
661
+ dependencies = [
662
+ "dirs-sys",
663
+ ]
664
+
665
+ [[package]]
666
+ name = "dirs-sys"
667
+ version = "0.5.0"
668
+ source = "registry+https://github.com/rust-lang/crates.io-index"
669
+ checksum = "e01a3366d27ee9890022452ee61b2b63a67e6f13f58900b651ff5665f0bb1fab"
670
+ dependencies = [
671
+ "libc",
672
+ "option-ext",
673
+ "redox_users",
674
+ "windows-sys 0.61.2",
675
+ ]
676
+
653
677
  [[package]]
654
678
  name = "document-features"
655
679
  version = "0.2.12"
@@ -719,6 +743,16 @@ version = "1.0.7"
719
743
  source = "registry+https://github.com/rust-lang/crates.io-index"
720
744
  checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
721
745
 
746
+ [[package]]
747
+ name = "fs2"
748
+ version = "0.4.3"
749
+ source = "registry+https://github.com/rust-lang/crates.io-index"
750
+ checksum = "9564fc758e15025b46aa6643b1b77d047d1a56a1aea6e01002ac0c7026876213"
751
+ dependencies = [
752
+ "libc",
753
+ "winapi",
754
+ ]
755
+
722
756
  [[package]]
723
757
  name = "futures"
724
758
  version = "0.3.34"
@@ -978,6 +1012,15 @@ version = "0.2.16"
978
1012
  source = "registry+https://github.com/rust-lang/crates.io-index"
979
1013
  checksum = "b6d2cec3eae94f9f509c767b45932f1ada8350c4bdb85af2fcab4a3c14807981"
980
1014
 
1015
+ [[package]]
1016
+ name = "libredox"
1017
+ version = "0.1.25"
1018
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1019
+ checksum = "61ff90caf6077a803a240f62fdbe88645a890bbca49ef8174c3cb0404362171d"
1020
+ dependencies = [
1021
+ "libc",
1022
+ ]
1023
+
981
1024
  [[package]]
982
1025
  name = "linux-raw-sys"
983
1026
  version = "0.12.1"
@@ -1066,9 +1109,9 @@ dependencies = [
1066
1109
 
1067
1110
  [[package]]
1068
1111
  name = "napi"
1069
- version = "3.12.2"
1112
+ version = "3.13.0"
1070
1113
  source = "registry+https://github.com/rust-lang/crates.io-index"
1071
- checksum = "58c5f4d5375213fdb7be2655e152386e82f026f9a5ba36a75556e11359aafe09"
1114
+ checksum = "3b12638855cec016784a7e17cc4ecbdee7ca8b0a3456aa50640d0ee5ed1a42f8"
1072
1115
  dependencies = [
1073
1116
  "anyhow",
1074
1117
  "bitflags",
@@ -1085,17 +1128,17 @@ dependencies = [
1085
1128
 
1086
1129
  [[package]]
1087
1130
  name = "napi-build"
1088
- version = "2.4.1"
1131
+ version = "2.5.0"
1089
1132
  source = "registry+https://github.com/rust-lang/crates.io-index"
1090
- checksum = "60fdf9b392c50e7c4170fa633bd909490ed7835cea4c046776d1a4dd8d2ae0ab"
1133
+ checksum = "0941983559cd62bfa7f04646a16428967a847365adeef27711e4e3927046bbed"
1091
1134
 
1092
1135
  [[package]]
1093
1136
  name = "napi-derive"
1094
- version = "3.6.3"
1137
+ version = "3.6.10"
1095
1138
  source = "registry+https://github.com/rust-lang/crates.io-index"
1096
- checksum = "0fa55ea69990c90b888e9e77044410e304ce7f35de599dc6d0b5c1923d2e59af"
1139
+ checksum = "d11174f7507d7f6cdd69874f541eff194e81c95652b775e69036bcf8d5b7a805"
1097
1140
  dependencies = [
1098
- "convert_case 0.11.0",
1141
+ "convert_case 0.12.0",
1099
1142
  "ctor",
1100
1143
  "napi-derive-backend",
1101
1144
  "proc-macro2",
@@ -1105,11 +1148,11 @@ dependencies = [
1105
1148
 
1106
1149
  [[package]]
1107
1150
  name = "napi-derive-backend"
1108
- version = "6.1.2"
1151
+ version = "6.1.4"
1109
1152
  source = "registry+https://github.com/rust-lang/crates.io-index"
1110
- checksum = "df4056ac7c18e4438ccf0edaed4340ca0d269278c8ec19284f7b23cb039fd0ae"
1153
+ checksum = "fd6856fe1686867da90ed0dc292d7c0c87a695eb7c578b913360f33619ee01e3"
1111
1154
  dependencies = [
1112
- "convert_case 0.11.0",
1155
+ "convert_case 0.12.0",
1113
1156
  "proc-macro2",
1114
1157
  "quote",
1115
1158
  "semver",
@@ -1118,9 +1161,9 @@ dependencies = [
1118
1161
 
1119
1162
  [[package]]
1120
1163
  name = "napi-sys"
1121
- version = "3.3.0"
1164
+ version = "3.3.2"
1122
1165
  source = "registry+https://github.com/rust-lang/crates.io-index"
1123
- checksum = "85fbf1fa9f1babfe396d74bbbf52b3643770243e8f5b0b46715d4caf7f0dfc9a"
1166
+ checksum = "6801fc65ba4d7035636e93635e281113f00410401a237dcd4f55b1565ead2115"
1124
1167
  dependencies = [
1125
1168
  "libloading",
1126
1169
  ]
@@ -1186,6 +1229,12 @@ version = "11.1.5"
1186
1229
  source = "registry+https://github.com/rust-lang/crates.io-index"
1187
1230
  checksum = "d6790f58c7ff633d8771f42965289203411a5e5c68388703c06e14f24770b41e"
1188
1231
 
1232
+ [[package]]
1233
+ name = "option-ext"
1234
+ version = "0.2.0"
1235
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1236
+ checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d"
1237
+
1189
1238
  [[package]]
1190
1239
  name = "parking_lot"
1191
1240
  version = "0.12.5"
@@ -1377,6 +1426,16 @@ dependencies = [
1377
1426
  "bitflags",
1378
1427
  ]
1379
1428
 
1429
+ [[package]]
1430
+ name = "redox_users"
1431
+ version = "0.5.3"
1432
+ source = "registry+https://github.com/rust-lang/crates.io-index"
1433
+ checksum = "60dc65c0ff1a7ae1294b0c67b9f14baf70b644404010370171787bfac1038fc0"
1434
+ dependencies = [
1435
+ "libredox",
1436
+ "thiserror 2.0.21",
1437
+ ]
1438
+
1380
1439
  [[package]]
1381
1440
  name = "ref-cast"
1382
1441
  version = "1.0.27"
@@ -1565,7 +1624,7 @@ dependencies = [
1565
1624
  "strum",
1566
1625
  "strum_macros",
1567
1626
  "syn 2.0.119",
1568
- "thiserror 2.0.20",
1627
+ "thiserror 2.0.21",
1569
1628
  "typed-builder",
1570
1629
  ]
1571
1630
 
@@ -1711,9 +1770,9 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
1711
1770
 
1712
1771
  [[package]]
1713
1772
  name = "smallvec"
1714
- version = "1.15.2"
1773
+ version = "1.16.2"
1715
1774
  source = "registry+https://github.com/rust-lang/crates.io-index"
1716
- checksum = "8ed6a63f02c8539c91a8685a86f4099661ba3da017932f6ebbea6de3f0fa7c90"
1775
+ checksum = "f9395f0f0eee849a9b707b2f06bb92a6a422090e2123bb2ef8e87a0e61892a8e"
1717
1776
 
1718
1777
  [[package]]
1719
1778
  name = "streaming-iterator"
@@ -1826,9 +1885,9 @@ dependencies = [
1826
1885
 
1827
1886
  [[package]]
1828
1887
  name = "termimad"
1829
- version = "0.35.2"
1888
+ version = "0.35.5"
1830
1889
  source = "registry+https://github.com/rust-lang/crates.io-index"
1831
- checksum = "bc986efe2e680fbd1051790103f01b176eb6b1bbc926e41d46adfe44ea43614c"
1890
+ checksum = "092b11fb38404fa873f019f8e5f300fa5787f381b7a58b923546d94b5a9065fd"
1832
1891
  dependencies = [
1833
1892
  "coolor",
1834
1893
  "crokey",
@@ -1836,7 +1895,7 @@ dependencies = [
1836
1895
  "lazy-regex",
1837
1896
  "minimad",
1838
1897
  "serde",
1839
- "thiserror 2.0.20",
1898
+ "thiserror 2.0.21",
1840
1899
  "unicode-width 0.1.14",
1841
1900
  ]
1842
1901
 
@@ -1848,7 +1907,7 @@ checksum = "23493cf1be461ed14d2c81bf1d39dcea17c8095d4f623b1a1292ea212f6b88ed"
1848
1907
  dependencies = [
1849
1908
  "coolor",
1850
1909
  "crossterm",
1851
- "thiserror 2.0.20",
1910
+ "thiserror 2.0.21",
1852
1911
  "xterm-query",
1853
1912
  ]
1854
1913
 
@@ -1869,11 +1928,11 @@ dependencies = [
1869
1928
 
1870
1929
  [[package]]
1871
1930
  name = "thiserror"
1872
- version = "2.0.20"
1931
+ version = "2.0.21"
1873
1932
  source = "registry+https://github.com/rust-lang/crates.io-index"
1874
- checksum = "ec86235f5fcc2a73650310756d2ac5b138a5780bbbdfae3eeccec992c435ba4f"
1933
+ checksum = "09e52cb86a36cede5cb101bf8908837b3e4c6e5e59fe7fd85c23fb56200d189e"
1875
1934
  dependencies = [
1876
- "thiserror-impl 2.0.20",
1935
+ "thiserror-impl 2.0.21",
1877
1936
  ]
1878
1937
 
1879
1938
  [[package]]
@@ -1889,9 +1948,9 @@ dependencies = [
1889
1948
 
1890
1949
  [[package]]
1891
1950
  name = "thiserror-impl"
1892
- version = "2.0.20"
1951
+ version = "2.0.21"
1893
1952
  source = "registry+https://github.com/rust-lang/crates.io-index"
1894
- checksum = "bc04cd3e1236dd4a98afca4569f2deb3f120e5422a4023be2cb683f8486292af"
1953
+ checksum = "fe5197923287db20a58125f0bc85c062f7f2c892de97b18c356f9efb14b28524"
1895
1954
  dependencies = [
1896
1955
  "proc-macro2",
1897
1956
  "quote",
@@ -1909,9 +1968,9 @@ dependencies = [
1909
1968
 
1910
1969
  [[package]]
1911
1970
  name = "tokio"
1912
- version = "1.53.1"
1971
+ version = "1.53.2"
1913
1972
  source = "registry+https://github.com/rust-lang/crates.io-index"
1914
- checksum = "202caea871b69668250d242070849eb495be178ed697a3e98aebce5bc81a0bed"
1973
+ checksum = "e95f91fcc7a621e8b030f6aa23c71fe9838ae2fb4d8118b75602a328f5144044"
1915
1974
  dependencies = [
1916
1975
  "bytes",
1917
1976
  "pin-project-lite",
@@ -1965,9 +2024,9 @@ dependencies = [
1965
2024
 
1966
2025
  [[package]]
1967
2026
  name = "toml_edit"
1968
- version = "0.25.13+spec-1.1.0"
2027
+ version = "0.25.15+spec-1.1.0"
1969
2028
  source = "registry+https://github.com/rust-lang/crates.io-index"
1970
- checksum = "6975367e4d2ef766d86af01ffad14b622fecc8d4357a998fbc4deb6e9bacaf9b"
2029
+ checksum = "1340ea94a5856333492c9064b02c778b191dd2c853778d9609debdcdfea3a614"
1971
2030
  dependencies = [
1972
2031
  "indexmap",
1973
2032
  "toml_datetime",
@@ -2100,13 +2159,12 @@ dependencies = [
2100
2159
 
2101
2160
  [[package]]
2102
2161
  name = "tree-sitter"
2103
- version = "0.26.13"
2162
+ version = "0.27.0"
2104
2163
  source = "registry+https://github.com/rust-lang/crates.io-index"
2105
- checksum = "17ebdd3a5a7e28a1890b876fdbd0c3c0fe0a6336cffaa104f11b9f720c9daa29"
2164
+ checksum = "2038684e0058edba0d17302619f62eabce4a8e11c6ac59506996a8d79848851d"
2106
2165
  dependencies = [
2107
2166
  "cc",
2108
2167
  "regex",
2109
- "regex-syntax",
2110
2168
  "serde_json",
2111
2169
  "streaming-iterator",
2112
2170
  "tree-sitter-language",
@@ -2264,9 +2322,9 @@ dependencies = [
2264
2322
 
2265
2323
  [[package]]
2266
2324
  name = "tree-sitter-language"
2267
- version = "0.1.7"
2325
+ version = "0.1.8"
2268
2326
  source = "registry+https://github.com/rust-lang/crates.io-index"
2269
- checksum = "009994f150cc0cd50ff54917d5bc8bffe8cad10ca10d81c34da2ec421ae61782"
2327
+ checksum = "ca0d1bf6fdd806e43ae5198f82f527056d359def39e54e67a0f478ac09dac081"
2270
2328
 
2271
2329
  [[package]]
2272
2330
  name = "tree-sitter-lua"
@@ -2388,6 +2446,16 @@ dependencies = [
2388
2446
  "tree-sitter-language",
2389
2447
  ]
2390
2448
 
2449
+ [[package]]
2450
+ name = "tree-sitter-zig"
2451
+ version = "1.1.2"
2452
+ source = "registry+https://github.com/rust-lang/crates.io-index"
2453
+ checksum = "ab11fc124851b0db4dd5e55983bbd9631192e93238389dcd44521715e5d53e28"
2454
+ dependencies = [
2455
+ "cc",
2456
+ "tree-sitter-language",
2457
+ ]
2458
+
2391
2459
  [[package]]
2392
2460
  name = "typed-builder"
2393
2461
  version = "0.21.2"
@@ -2487,7 +2555,7 @@ checksum = "ccf3ec651a847eb01de73ccad15eb7d99f80485de043efb2f370cd654f4ea44b"
2487
2555
 
2488
2556
  [[package]]
2489
2557
  name = "wasm"
2490
- version = "0.45.2"
2558
+ version = "0.50.0"
2491
2559
  dependencies = [
2492
2560
  "ast-grep-config",
2493
2561
  "ast-grep-core",
@@ -6,7 +6,7 @@ resolver = "2"
6
6
  lto = true
7
7
 
8
8
  [workspace.package]
9
- version = "0.45.2"
9
+ version = "0.50.0"
10
10
  authors = ["Herrington Darkholme <2883231+HerringtonDarkholme@users.noreply.github.com>"]
11
11
  edition = "2024"
12
12
  license = "MIT"
@@ -17,12 +17,12 @@ rust-version = "1.88.0"
17
17
  readme = "README.md"
18
18
 
19
19
  [workspace.dependencies]
20
- ast-grep-core = { path = "crates/core", version = "0.45.2", default-features = false }
21
- ast-grep-config = { path = "crates/config", version = "0.45.2" }
22
- ast-grep-dynamic = { path = "crates/dynamic", version = "0.45.2" }
23
- ast-grep-language = { path = "crates/language", version = "0.45.2" }
24
- ast-grep-lsp = { path = "crates/lsp", version = "0.45.2" }
25
- ast-grep-outline = { path = "crates/outline", version = "0.45.2" }
20
+ ast-grep-core = { path = "crates/core", version = "0.50.0", default-features = false }
21
+ ast-grep-config = { path = "crates/config", version = "0.50.0" }
22
+ ast-grep-dynamic = { path = "crates/dynamic", version = "0.50.0" }
23
+ ast-grep-language = { path = "crates/language", version = "0.50.0" }
24
+ ast-grep-lsp = { path = "crates/lsp", version = "0.50.0" }
25
+ ast-grep-outline = { path = "crates/outline", version = "0.50.0" }
26
26
 
27
27
  bit-set = { version = "0.11.0" }
28
28
  ignore = { version = "0.4.22" }
@@ -30,7 +30,7 @@ regex = { version = "1.10.4" }
30
30
  serde = { version = "1.0.200", features = ["derive"] }
31
31
  serde_regex = "1.2.0"
32
32
  serde_yaml = "0.9.33"
33
- tree-sitter = { version = "0.26.3" }
33
+ tree-sitter = { version = "0.27.0" }
34
34
  thiserror = "2.0.0"
35
35
  schemars = "1.0.0"
36
36
  anyhow = "1.0.82"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ast-grep-cli
3
- Version: 0.45.2
3
+ Version: 0.50.0
4
4
  Classifier: Development Status :: 3 - Alpha
5
5
  Classifier: Environment :: Console
6
6
  Classifier: Intended Audience :: Developers
@@ -38,6 +38,8 @@ anyhow.workspace = true
38
38
  clap = { version = "4.5.4", features = ["derive"] }
39
39
  codespan-reporting = "0.13.0"
40
40
  crossterm = "0.29.0"
41
+ directories = "6.0.0"
42
+ fs2 = "0.4.3"
41
43
  ignore.workspace = true
42
44
  regex.workspace = true
43
45
  dashmap.workspace = true
@@ -50,6 +52,7 @@ serde_yaml.workspace = true
50
52
  serde-sarif = "0.8.0"
51
53
  similar = { version = "3.0.0", features = ["inline"] }
52
54
  smallvec = "1.13.2"
55
+ tempfile = "3.10.1"
53
56
  tokio = { version = "1.37.0", features = ["rt-multi-thread", "io-std"] }
54
57
  clap_complete = "4.5.2"
55
58
  tracing-subscriber = { version = "0.3", features = ["env-filter"] }
@@ -57,7 +60,6 @@ tracing-subscriber = { version = "0.3", features = ["env-filter"] }
57
60
  [dev-dependencies]
58
61
  assert_cmd = "2.0.14"
59
62
  predicates = "3.1.0"
60
- tempfile = "3.10.1"
61
63
 
62
64
  # Support cargo bininstall, https://github.com/ast-grep/ast-grep/issues/1742
63
65
  [package.metadata.binstall]
@@ -1,3 +1,4 @@
1
+ use crate::custom_language::CustomLanguageAction;
1
2
  use crate::lang::{CustomLang, LanguageGlobs, SerializableInjection, SgLang};
2
3
  use crate::utils::{ErrorContext as EC, RuleOverwrite, RuleTrace};
3
4
 
@@ -75,6 +76,7 @@ impl ProjectConfig {
75
76
  let Some(config_path) = config_path else {
76
77
  return Ok(None);
77
78
  };
79
+ let config_path = config_path.canonicalize().context(EC::ReadConfiguration)?;
78
80
  let config_str = read_to_string(&config_path).context(EC::ReadConfiguration)?;
79
81
  let sg_config: AstGrepConfig = from_str(&config_str).context(EC::ParseConfiguration)?;
80
82
  let project_dir = config_path
@@ -95,21 +97,27 @@ impl ProjectConfig {
95
97
  /// returns a Result of Result.
96
98
  /// The inner Result is for configuration not found, or ProjectNotExist
97
99
  /// The outer Result is for definitely wrong config.
98
- pub fn setup(config_path: Option<PathBuf>) -> Result<Result<Self>> {
100
+ pub fn setup(
101
+ config_path: Option<PathBuf>,
102
+ custom_languages: CustomLanguageAction,
103
+ ) -> Result<Result<Self>> {
99
104
  let Some((project_dir, mut sg_config)) = Self::discover_project(config_path)? else {
100
105
  return Ok(Err(anyhow::anyhow!(EC::ProjectNotExist)));
101
106
  };
102
- let outline_rules =
103
- custom_language_outline_rules(&project_dir, sg_config.custom_languages.as_ref());
107
+ let outline_rules = if custom_languages == CustomLanguageAction::Load {
108
+ custom_language_outline_rules(&project_dir, sg_config.custom_languages.as_ref())
109
+ } else {
110
+ vec![]
111
+ };
104
112
  let config = ProjectConfig {
105
113
  project_dir,
106
- rule_dirs: sg_config.rule_dirs.drain(..).collect(),
114
+ rule_dirs: std::mem::take(&mut sg_config.rule_dirs),
107
115
  outline_rules,
108
116
  test_configs: sg_config.test_configs.take(),
109
117
  util_dirs: sg_config.util_dirs.take(),
110
118
  };
111
119
  // sg_config will not use rule dirs and test configs anymore
112
- register_custom_language(&config.project_dir, sg_config)?;
120
+ register_custom_language(&config.project_dir, sg_config, custom_languages)?;
113
121
  Ok(Ok(config))
114
122
  }
115
123
  }
@@ -126,9 +134,23 @@ fn custom_language_outline_rules(
126
134
  .collect()
127
135
  }
128
136
 
129
- fn register_custom_language(project_dir: &Path, sg_config: AstGrepConfig) -> Result<()> {
137
+ fn register_custom_language(
138
+ project_dir: &Path,
139
+ sg_config: AstGrepConfig,
140
+ action: CustomLanguageAction,
141
+ ) -> Result<()> {
130
142
  if let Some(custom_langs) = sg_config.custom_languages {
131
- SgLang::register_custom_language(project_dir, custom_langs)?;
143
+ match action {
144
+ CustomLanguageAction::Load => {
145
+ SgLang::register_custom_language(project_dir, custom_langs)?;
146
+ }
147
+ CustomLanguageAction::Ignore if !custom_langs.is_empty() => {
148
+ eprintln!(
149
+ "Warning: custom languages are ignored because native libraries can execute malicious code. Review the project before using `--custom-languages allow`."
150
+ );
151
+ }
152
+ CustomLanguageAction::Ignore => {}
153
+ }
132
154
  }
133
155
  if let Some(globs) = sg_config.language_globs {
134
156
  SgLang::register_globs(globs)?;
@@ -277,7 +299,9 @@ const CONFIG_FILE_YML: &str = "sgconfig.yml";
277
299
  const CONFIG_FILE_YAML: &str = "sgconfig.yaml";
278
300
 
279
301
  /// return None if config file does not exist
280
- fn find_config_path_with_default(config_path: Option<PathBuf>) -> Result<Option<PathBuf>> {
302
+ pub(crate) fn find_config_path_with_default(
303
+ config_path: Option<PathBuf>,
304
+ ) -> Result<Option<PathBuf>> {
281
305
  if config_path.is_some() {
282
306
  return Ok(config_path);
283
307
  }
@@ -301,6 +325,8 @@ fn find_config_path_with_default(config_path: Option<PathBuf>) -> Result<Option<
301
325
  #[cfg(test)]
302
326
  mod tests {
303
327
  use super::*;
328
+ use std::fs;
329
+ use tempfile::TempDir;
304
330
 
305
331
  #[test]
306
332
  fn custom_language_outline_rules_are_project_relative() {
@@ -320,4 +346,31 @@ customLanguages:
320
346
 
321
347
  assert_eq!(paths, vec![PathBuf::from("/project/outline/blade.yml")]);
322
348
  }
349
+
350
+ #[cfg(unix)]
351
+ #[test]
352
+ fn symlinked_config_uses_canonical_project_directory() {
353
+ use std::os::unix::fs::symlink;
354
+
355
+ let root = TempDir::new().expect("temporary directory should be created");
356
+ let project = root.path().join("project");
357
+ let links = root.path().join("links");
358
+ fs::create_dir_all(&project).expect("project directory should be created");
359
+ fs::create_dir_all(&links).expect("link directory should be created");
360
+ let config = project.join("sgconfig.yml");
361
+ fs::write(&config, "ruleDirs: []\n").expect("configuration should be written");
362
+ let linked_config = links.join("sgconfig.yml");
363
+ symlink(&config, &linked_config).expect("configuration symlink should be created");
364
+
365
+ let (project_dir, _) = ProjectConfig::discover_project(Some(linked_config))
366
+ .expect("configuration should be discovered")
367
+ .expect("project should exist");
368
+
369
+ assert_eq!(
370
+ project_dir,
371
+ project
372
+ .canonicalize()
373
+ .expect("project directory should be canonicalized")
374
+ );
375
+ }
323
376
  }