Skip to content

Commit c17f8a2

Browse files
committed
refactor(domain-dict): reduce entry batch size and disable TreeSitter parsing
Limit processed names to 1000 per batch and comment out TreeSitter-based hot file parsing to improve performance. Switch codebase analysis type to "imports" for faster insights.
1 parent 9b5da4d commit c17f8a2

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

mpp-core/src/commonMain/kotlin/cc/unitmesh/agent/subagent/DomainDictAgent.kt

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ class DomainDictAgent(
185185
// ============= Step 2: Generate Entries =============
186186
onProgress("\n## Step 2/3: Generating Entries")
187187

188-
val namesToProcess = newNames.take(3000)
188+
val namesToProcess = newNames.take(1000)
189189
onProgress(" 💭 Translating ${namesToProcess.size} terms (of ${newNames.size} total)...")
190190

191191
val newEntries = generateEntries(namesToProcess, callbacks)
@@ -249,8 +249,9 @@ class DomainDictAgent(
249249
): CodebaseInsightsResult? {
250250
onProgress(" 🔍 Scanning Git history and code structure...")
251251

252+
// since git and full type slowly, we use improts only
252253
val params = CodebaseInsightsParams(
253-
analysisType = "full",
254+
analysisType = "imports",
254255
maxFiles = 3000,
255256
focusArea = focusArea
256257
)
@@ -273,24 +274,18 @@ class DomainDictAgent(
273274
return result
274275
}
275276

276-
/**
277-
* Extract meaningful names from TWO sources:
278-
* 1. Hot files (TreeSitter parsing) - core business logic
279-
* 2. All domain concepts (480+ concepts from full codebase analysis)
280-
*/
281-
private suspend fun extractMeaningfulNames(
277+
suspend fun extractMeaningfulNames(
282278
insights: CodebaseInsightsResult,
283279
onProgress: (String) -> Unit
284280
): List<String> {
285281
val hotFileNames = mutableSetOf<String>()
286282
val allConceptNames = mutableSetOf<String>()
287-
288-
// ========== Source 1: Hot Files (TreeSitter deep parsing) ==========
289-
if (codeParser != null) {
290-
onProgress(" 🌲 Using TreeSitter to parse hot files...")
291-
val hotFilesWithCode = parseHotFilesWithTreeSitter(insights.hotFiles, onProgress)
292-
hotFileNames.addAll(hotFilesWithCode)
293-
}
283+
// since it's lowly we just disable it
284+
// if (codeParser != null) {
285+
// onProgress(" 🌲 Using TreeSitter to parse hot files...")
286+
// val hotFilesWithCode = parseHotFilesWithTreeSitter(insights.hotFiles, onProgress)
287+
// hotFileNames.addAll(hotFilesWithCode)
288+
// }
294289

295290
// Also extract from hot file names
296291
for (file in insights.hotFiles) {
@@ -310,24 +305,18 @@ class DomainDictAgent(
310305
}
311306

312307
onProgress(" 🔥 Hot files: ${hotFileNames.size} concepts")
313-
314-
// ========== Source 2: All Domain Concepts (from full codebase) ==========
315308
onProgress(" 📚 Processing ${insights.domainConcepts.size} codebase concepts...")
316-
317-
// Sort by occurrences (more frequent = more important)
318309
val sortedConcepts = insights.domainConcepts.sortedByDescending { it.occurrences }
319310

320311
for (concept in sortedConcepts) {
321312
val name = concept.name
322-
// Less strict filter for domain concepts (they're already extracted from code)
323313
if (isValidDomainConceptName(name)) {
324314
allConceptNames.add(name)
325315
}
326316
}
327317

328318
onProgress(" 📋 All concepts: ${allConceptNames.size} valid names")
329319

330-
// Merge: Hot files first (priority), then all concepts
331320
val result = mutableListOf<String>()
332321
result.addAll(hotFileNames.sorted())
333322
result.addAll(allConceptNames.filter { it !in hotFileNames }.sorted())
@@ -655,6 +644,7 @@ $namesList
655644
if (enableStreaming) {
656645
try {
657646
llmService.streamPrompt(prompt, compileDevIns = false).collect { chunk ->
647+
print(chunk)
658648
response.append(chunk)
659649
callbacks.onAIThinking(chunk)
660650
}

0 commit comments

Comments
 (0)