Understand any codebase instantly. System intelligence for codebases, built for humans and AI.
TypeScript aiai-memoryclaude-codeclicode-analysiscode-mappingcode-memorycodebase-understandingcodexdeveloper-toolsllmopenclawpersistent-memoryprogram-analysissoftware-architecturesystem-intelligencesystem-mapping
feat: add expandByName for cross-file CALLS resolution
riley0227ea9f6696252c
diff --git a/memory-layer/src/main/scala/ix/memory/api/ExpandRoutes.scala b/memory-layer/src/main/scala/ix/memory/api/ExpandRoutes.scalaindex e1290276..5ec79082 100644--- a/memory-layer/src/main/scala/ix/memory/api/ExpandRoutes.scala+++ b/memory-layer/src/main/scala/ix/memory/api/ExpandRoutes.scala@@ -25,6 +25,17 @@ object ExpandRequest {implicit val decoder: Decoder[ExpandRequest] = deriveDecoder[ExpandRequest]}+case class ExpandByNameRequest(+ name: String,+ direction: Option[String] = None,+ predicates: Option[List[String]] = None,+ kinds: Option[List[String]] = None+)++object ExpandByNameRequest {+ implicit val decoder: Decoder[ExpandByNameRequest] = deriveDecoder[ExpandByNameRequest]+}+class ExpandRoutes(queryApi: GraphQueryApi) {val routes: HttpRoutes[IO] = HttpRoutes.of[IO] {@@ -43,5 +54,21 @@ class ExpandRoutes(queryApi: GraphQueryApi) {result <- queryApi.expand(nodeId, dir, preds, body.hops.getOrElse(1), body.asOfRev.map(Rev(_)))resp <- Ok(result.asJson)} yield resp).handleErrorWith(ErrorHandler.handle(_))++ case req @ POST -> Root / "v1" / "expand-by-name" =>+ (for {+ body <- req.as[ExpandByNameRequest]+ dir = body.direction match {+ case Some("in") => Direction.In+ case Some("out") => Direction.Out+ case _ => Direction.Both+ }+ preds = body.predicates.map(_.toSet)+ kinds = body.kinds.map(_.flatMap(k =>+ NodeKind.decoder.decodeJson(io.circe.Json.fromString(k)).toOption+ ).toSet)+ result <- queryApi.expandByName(body.name, dir, preds, kinds)+ resp <- Ok(result.asJson)+ } yield resp).handleErrorWith(ErrorHandler.handle(_))}}diff --git a/memory-layer/src/main/scala/ix/memory/db/ArangoGraphQueryApi.scala b/memory-layer/src/main/scala/ix/memory/db/ArangoGraphQueryApi.scalaindex a3ee6cba..d04033b2 100644--- a/memory-layer/src/main/scala/ix/memory/db/ArangoGraphQueryApi.scala+++ b/memory-layer/src/main/scala/ix/memory/db/ArangoGraphQueryApi.scala@@ -342,6 +342,73 @@ class ArangoGraphQueryApi(client: ArangoClient) extends GraphQueryApi {}}+ override def expandByName(+ name: String,+ direction: Direction,+ predicates: Option[Set[String]] = None,+ kinds: Option[Set[NodeKind]] = None+ ): IO[ExpandResult] = {+ val kindFilter = kinds.filter(_.nonEmpty) match {+ case Some(_) => " AND n.kind IN @kinds"+ case None => ""+ }+ val predicateFilter = predicates.filter(_.nonEmpty) match {+ case Some(_) => " AND e.predicate IN @predicates"+ case None => ""+ }+ val directionFilter = direction match {+ case Direction.Out => "FILTER e.src IN target_ids"+ case Direction.In => "FILTER e.dst IN target_ids"+ case Direction.Both => "FILTER e.src IN target_ids OR e.dst IN target_ids"+ }++ val aql =+ s"""LET target_ids = (+ | FOR n IN nodes+ | FILTER n.name == @name AND n.deleted_rev == null+ | $kindFilter+ | RETURN DISTINCT n.logical_id+ |)+ |FOR e IN edges+ | FILTER e.deleted_rev == null+ | $directionFilter+ | $predicateFilter+ | LET other_id = (e.src IN target_ids ? e.dst : e.src)+ | LET other = FIRST(+ | FOR n IN nodes+ | FILTER n.logical_id == other_id AND n.deleted_rev == null+ | SORT n.created_rev DESC+ | LIMIT 1+ | RETURN n+ | )+ | FILTER other != null+ | RETURN { edge: e, node: other }""".stripMargin++ val binds = scala.collection.mutable.Map[String, AnyRef](+ "name" -> name.asInstanceOf[AnyRef]+ )+ kinds.filter(_.nonEmpty).foreach { ks =>+ val kindList = new java.util.ArrayList[String]()+ ks.foreach(k => kindList.add(nodeKindToString(k)))+ binds += ("kinds" -> kindList.asInstanceOf[AnyRef])+ }+ predicates.filter(_.nonEmpty).foreach { ps =>+ val predList = new java.util.ArrayList[String]()+ ps.foreach(predList.add)+ binds += ("predicates" -> predList.asInstanceOf[AnyRef])+ }++ client.query(aql, binds.toMap).map { results =>+ val edges = results.flatMap { json =>+ json.hcursor.downField("edge").focus.flatMap(parseEdge)+ }.toVector+ val nodes = results.flatMap { json =>+ json.hcursor.downField("node").focus.flatMap(parseNode)+ }.toVector+ ExpandResult(nodes, edges)+ }+ }+// ── JSON Parsers (snake_case → camelCase) ───────────────────────────private def parseNode(json: Json): Option[GraphNode] = {diff --git a/memory-layer/src/main/scala/ix/memory/db/GraphQueryApi.scala b/memory-layer/src/main/scala/ix/memory/db/GraphQueryApi.scalaindex d1500e45..74c2f120 100644--- a/memory-layer/src/main/scala/ix/memory/db/GraphQueryApi.scala+++ b/memory-layer/src/main/scala/ix/memory/db/GraphQueryApi.scala@@ -21,6 +21,12 @@ trait GraphQueryApi {def getChangedEntities(fromRev: Rev, toRev: Rev): IO[Vector[(GraphNode, Option[GraphNode])]]def resolvePrefix(prefix: String): IO[Vector[NodeId]]def getSourceHashes(sourceUris: Seq[String]): IO[Map[String, String]]+ def expandByName(+ name: String,+ direction: Direction,+ predicates: Option[Set[String]] = None,+ kinds: Option[Set[NodeKind]] = None+ ): IO[ExpandResult]}sealed trait Direction