Skip to content

Commit a7f1712

Browse files
Add packages section and update existing docs for ast-grep
1 parent cc209ad commit a7f1712

File tree

1 file changed

+58
-3
lines changed

1 file changed

+58
-3
lines changed

docs/guides/prompt-customization.md

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,19 @@ By default, you can add `ast-grep` rules by following these steps:
7373
review process.
7474
5. Add the rules' directory to the `.coderabbit.yml` file under `tools.ast-grep`
7575
configuration.
76+
6. Optionally, you can add `packages` property to the configuration to specify
77+
the packages that should be installed before running the `ast-grep` tool. Please read the `packages` section for detailed information.
7678

7779
```yaml
7880
#...
7981
reviews:
8082
#...
8183
tools:
8284
ast-grep:
83-
rules_directory: "custom-name"
85+
rule_dirs:
86+
- "custom-name"
87+
packages:
88+
- "ast-grep-essentials" # default package installed
8489
#...
8590
```
8691

@@ -247,14 +252,23 @@ my-awesome-project # project root
247252
> Also, you need to add the `rules` and `utils` directories to the
248253
> `.coderabbit.yml` file under `tools.ast-grep` configuration.
249254

255+
> The rules can also be inside a package. If you have a package that contains
256+
rules, you can add the package name to the `packages` field in the
257+
`.coderabbit.yml` file.
258+
250259
```yaml
251260
#...
252261
reviews:
253262
#...
254263
tools:
255264
ast-grep:
256-
rules_directory: "rules"
257-
utils_directory: "utils"
265+
rule_dirs:
266+
- "rules"
267+
util_dirs:
268+
- "utils"
269+
packages:
270+
- "ast-grep-essentials"
271+
- "my-awesome-org/my-awesome-package" # public repository that contains ast-grep rules
258272
#...
259273
```
260274

@@ -276,6 +290,47 @@ rule:
276290
> Official documentation guide on
277291
> [Utility Rule](https://ast-grep.github.io/guide/rule-config/utility-rule.html)
278292

293+
### Packages
294+
A package is what allows you to share rules across multiple projects. Essentially a package is a collection of ast-grep rules.
295+
296+
Coderabbit provides a set of packages that you can use out of the box. You can also create your own packages and share them with the community or just
297+
use them within your organization.
298+
299+
Packages provided by Coderabbit are:
300+
- `ast-grep-essentials`: A set of essential security rules
301+
302+
To use a package, you need to add the package name to the `packages` field in the `.coderabbit.yml` file.
303+
304+
```yaml
305+
#...
306+
reviews:
307+
#...
308+
tools:
309+
ast-grep:
310+
packages:
311+
- "ast-grep-essentials"
312+
#...
313+
```
314+
315+
#### Using custom package
316+
Let's say that you have a public repository that contains ast-grep rules. You can add the package name to the `packages` field in the `.coderabbit.yml` file.
317+
318+
Requirements for a package:
319+
- should be a public repository
320+
- contains rules that follows the ast-grep rule format
321+
- package name should be in the format `organization/repository`
322+
323+
```yaml
324+
#...
325+
reviews:
326+
#...
327+
tools:
328+
ast-grep:
329+
packages:
330+
- "my-awesome-org/my-awesome-package"
331+
#...
332+
```
333+
279334
### Multiple Languages Support
280335

281336
CodeRabbit supports multiple programming languages for defining `ast-grep`

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy