Skip to content

Commit 6140691

Browse files
committed
feat(devin-lang): add support for writing content to a file #101
The commit introduces a new feature to the devin-lang extension, allowing users to write content to a file using the `write` command. This command enables the modification of files within the development environment, enhancing the language's capabilities for file manipulation. The syntax for the `write` command is specified as `/write:/path/to/file:L1-C2`, where the path points to the file to be written to, and the line and column numbers define the range of content to be replaced. This feature is implemented in `BuiltinAgentProvider.kt` by adding a new entry for the `WRITE` command, and two new test cases are added to `DevInParsingTest.kt` to ensure its correct functionality.
1 parent 36cd82e commit 6140691

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

exts/devin-lang/src/main/kotlin/cc/unitmesh/devti/language/completion/BuiltinAgentProvider.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ enum class BuiltinAgent(val agentName: String, val description: String) {
99
FILE("file", "Read the content of a file"),
1010
REV("rev", "Read git revision of a file"),
1111
SYMBOL("symbol", "Read content by Java/Kotlin canonicalName"),
12+
WRITE("write", "Write content to a file, format: /write:/path/to/file:L1-C2"),
1213
;
1314

1415
companion object {

exts/devin-lang/src/test/kotlin/cc/unitmesh/language/DevInParsingTest.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,8 @@ class DevInParsingTest : ParsingTestCase("parser", "devin", DevInParserDefinitio
3131
fun testComplexLangId() {
3232
doTest(true)
3333
}
34+
35+
fun testAutoCommand() {
36+
doTest(true)
37+
}
3438
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@write:Sample.file#L1-L12
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
DevInFile
2+
DevInUsedImpl(USED)
3+
PsiElement(DevInTokenType.AGENT_START)('@')
4+
PsiElement(DevInTokenType.AGENT_ID)('write')
5+
PsiElement(DevInTokenType.COLON)(':')
6+
PsiElement(DevInTokenType.PROPERTY_VALUE)('Sample.file#L1-L12')

0 commit comments

Comments
 (0)