Skip to content

Commit d3637f6

Browse files
committed
feat(compiler): limit directory listing depth to 2
Add a max depth limit of 2 for directory listing in the DirInsCommand. Update the output message to include depth information. This change ensures consistent and concise directory tree displays.
1 parent 9a8aa30 commit d3637f6

File tree

3 files changed

+8
-4
lines changed
  • core/src/main/resources/genius/zh/code
  • exts/devins-lang/src/main

3 files changed

+8
-4
lines changed

core/src/main/resources/genius/zh/code/bridge.vm

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ Here is an example output to the USER:
7878
请允许我调用工具来获取这些信息,以便为您提供更好的帮助:
7979
<devin>
8080
/file:README.md [注释:获取项目的 README 文件,了解项目的基本信息]
81-
/scc [注释:获取代码规模信息,优先考虑]
82-
/dir:. [注释:获取项目文件夹信息和目录结构,方便后续继续分析]
81+
/scc [注释:获取代码规模信息,请先获取代码规模信息]
8382
/dependencies [注释:获取项目依赖信息]
8483
/containerView [注释:获取项目模块信息,如果是多模块项目]
8584
/file:build.gradle [注释:获取项目构建文件信息,如果当前项目使用的是 build.gradle ]
@@ -94,7 +93,7 @@ Here is an example output to the USER:
9493
// 根据先前的信息,你得考虑是否需要调整迁移计划。
9594
根据您提供的信息,这是一个 xx 项目....,在继续之前,我需要确认这个信息。请允许我调用工具来获取这些信息:
9695
<devin>
97-
/dir:. [注释:如果先前没有获取目录信息,你需要再次获取]
96+
/dir:. [注释:在规模不在情况才能调用 dir]
9897
/file:build.gradle
9998
/file:build.gradle.kts
10099
/file:settings.gradle.kts

exts/devins-lang/src/main/kotlin/cc/unitmesh/devti/language/compiler/exec/DirInsCommand.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ class DirInsCommand(private val myProject: Project, private val dir: String) : I
5656
}
5757

5858
private val output = StringBuilder()
59+
private val maxLength = 2
5960

6061
override suspend fun execute(): String? {
6162
val virtualFile = myProject.lookupFile(dir) ?: return "File not found: $dir"
@@ -73,7 +74,9 @@ class DirInsCommand(private val myProject: Project, private val dir: String) : I
7374

7475
output.appendLine("$dir/")
7576
runReadAction { listDirectory(myProject!!, psiDirectory, 1) }
76-
future.complete(output.toString())
77+
future.complete(
78+
"Here is the directory tree (depth = 2) for $dir:\n$output"
79+
)
7780
}
7881
}
7982

@@ -84,6 +87,7 @@ class DirInsCommand(private val myProject: Project, private val dir: String) : I
8487
}
8588

8689
private fun listDirectory(project: Project, directory: PsiDirectory, depth: Int) {
90+
if (depth > maxLength) return
8791
if (isExclude(project, directory)) return
8892

8993
val files = directory.files
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
List the contents of a directory in 2 depth
12
/dir:src

0 commit comments

Comments
 (0)