Skip to content

Commit d343e5b

Browse files
committed
feat(core): add support for .devin files in project rules #349
- Update ProjectRule class to check for .devin files - Add .devin file support in getAllRules method - Update documentation to mention .devin file usage - Rename proejct-rule.md to project-rule.md in documentation
1 parent e3ad581 commit d343e5b

File tree

4 files changed

+49
-32
lines changed

4 files changed

+49
-32
lines changed

core/src/main/kotlin/cc/unitmesh/devti/sketch/rule/ProjectRule.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ class ProjectRule(private val project: Project) {
2525
return "<user-rule>\n$content\n</user-rule>"
2626
}
2727

28+
/// try .devin file
29+
val devinFile = project.lookupFile("$RULE_PATH/$filename.devin")
30+
if (devinFile != null) {
31+
val content = devinFile.readText()
32+
return "<user-rule>\n$content\n</user-rule>"
33+
}
34+
2835
return file
2936
}
3037

@@ -39,6 +46,6 @@ class ProjectRule(private val project: Project) {
3946
*/
4047
fun getAllRules(): List<VirtualFile> {
4148
val ruleDir = project.guessProjectDir()?.findFileByRelativePath(RULE_PATH) ?: return emptyList()
42-
return ruleDir.children.filter { it.extension == "md" }
49+
return ruleDir.children.filter { it.extension == "md" || it.extension == "devin" }
4350
}
4451
}

docs/composer/custom-ai-composer.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ nav_order: 1
99

1010
## Custom AI Composer
1111

12-
follow [Prompt Override](/customize/prompt-override), the AI Composer can be customized. in the `prompt/code` folder,
13-
you can create a file named `sketch.vm` to override the composer prompt.
12+
follow [Prompt Override](/customize/prompt-override), the AI Composer can be customized. in the `prompt/code` folder,
13+
you can create a file named [`sketch.vm`](https://github.com/unit-mesh/auto-dev/blob/master/core/src/main/resources/genius/zh/code/sketch.vm)
14+
to override the composer prompt.
1415

1516
## Use RipgrepSearch
1617

17-
Since we don't have a full-text search feature, you can use `RipgrepSearch` to search for files in the project. You can install it via Homebrew:
18+
Since we don't have a full-text search feature, you can use `RipgrepSearch` to search for files in the project. You can
19+
install it via Homebrew:
1820

1921
```bash
2022
brew install ripgrep

docs/composer/proejct-rule.md

Lines changed: 0 additions & 28 deletions
This file was deleted.

docs/composer/project-rule.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
layout: default
3+
title: Project Rule
4+
parent: AutoDev Sketch/Composer
5+
nav_order: 3
6+
---
7+
8+
# Project Rule
9+
10+
Notes: We prefer to use [prompts override](https://ide.unitmesh.cc/customize/prompt-override.html) to customize the
11+
prompt, but if you want to use the project rule, you can use the following method to customize the prompt.
12+
13+
Since @2.0.2 version, AutoDev supports project rule. The project rule is a set of rules that are used to validate the
14+
project structure and configuration. The project rule is defined under `prompts/rules` directory.
15+
16+
## Project Rule Example
17+
18+
The project rule is a Markdown file that contains the following fields:
19+
20+
For example, the project rule file is defined as follows:
21+
22+
```bash
23+
prompts/rules/
24+
├── service.md
25+
├── controller.md
26+
├── repository.md
27+
├── rpc.md
28+
└── README.md # will always load this file default !!
29+
```
30+
31+
Then the AutoDev will auto handle the project rule by RuleInsCommand, you can use the following command to check the project
32+
rule:
33+
34+
```devin
35+
/rule:service
36+
```

0 commit comments

Comments
 (0)