mcp: сервер memo_search/memo_status/memo_reindex

This commit is contained in:
2026-10-02 01:44:45 +03:00
parent f1d497d336
commit f2956e3cef
6 changed files with 586 additions and 75 deletions
@@ -0,0 +1,31 @@
package memo.core
import java.io.File
fun resolveCollection(path: File): File {
return if (path.name == ".memo") path.parentFile ?: path else path
}
fun findCollections(root: File): List<File> {
if (!root.isDirectory) return emptyList()
val candidates = LinkedHashSet<File>()
candidates.add(root)
val q = ArrayDeque<Pair<File, Int>>()
q.addLast(root to 0)
while (q.isNotEmpty()) {
val (d, depth) = q.removeFirst()
if (depth >= 2) continue
val children = d.listFiles() ?: continue
for (c in children) {
if (c.isDirectory && !c.name.startsWith(".")) {
candidates.add(c)
q.addLast(c to depth + 1)
}
}
}
return candidates.filter { d ->
d.walkTopDown()
.maxDepth(8)
.any { it.isFile && it.extension == "md" }
}
}