Skip to content

Commit 4a02594

Browse files
committed
feat(devti): support project rule in AutoDev Sketch/Composer #349
- Add project rule support for validating project structure and configuration - Define project rules under `prompts/rules` directory - Support loading default README.md file in project rules - Update SketchRunContext to handle project rules - Add documentation for project rule usage
1 parent c8f4393 commit 4a02594

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

core/src/main/kotlin/cc/unitmesh/devti/sketch/SketchRunContext.kt

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,21 @@ data class SketchRunContext(
7070

7171
val otherFiles = FileEditorManager.getInstance(project).openFiles.filter { it != currentFile }
7272

73-
val rules = ProjectRule(project).getAllRules().map { it.nameWithoutExtension }
73+
val projectRule = ProjectRule(project)
74+
val rules = projectRule.getAllRules().map { it.nameWithoutExtension }
7475
val rule = if (rules.isNotEmpty()) {
75-
"- User custom coding rule: [" + rules.joinToString(",") { it } + "]"
76+
val allRules = "- User custom coding rules file:" + rules.joinToString(",") { it }
77+
val string = if (projectRule.hasRule("README")) {
78+
projectRule.getRuleContent("README")?.let {
79+
"<rule> $it </rule>"
80+
} ?: ""
81+
} else ""
82+
83+
if (string.isNotEmpty()) {
84+
allRules + "\n" + string
85+
} else {
86+
allRules
87+
}
7688
} else {
7789
""
7890
}

docs/composer/proejct-rule.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
---
2+
layout: default
3+
title: Project Rule
4+
parent: AutoDev Sketch/Composer
5+
nav_order: 3
6+
---
7+
8+
# Project Rule
9+
10+
Since @2.0.2 version, AutoDev supports project rule. The project rule is a set of rules that are used to validate the project
11+
structure and configuration. The project rule is defined under `prompts/rules` directory. The project rule is a Markdown file that contains the following fields:
12+
13+
For example, the project rule file is defined as follows:
14+
15+
```bash
16+
promtps/rules/
17+
├── service.md
18+
├── controller.md
19+
├── rpc.md
20+
└── README.md # will always load this file default !!
21+
```
22+
23+
Then the LLM will auto handle the project rule by RuleInsCommand, like:
24+
25+
```devin
26+
/rule:service
27+
```

0 commit comments

Comments
 (0)