Skip to content

armgit / Ix

Public Imported from GitHub
0

Understand any codebase instantly. System intelligence for codebases, built for humans and AI.

feat: fixed optimization added install script (don't use)

kagebinaryb6e84790a7c8
diff --git a/ix-cli/src/cli/commands/impact.ts b/ix-cli/src/cli/commands/impact.ts
index f4f21a0d..bfd31e3d 100644
--- a/ix-cli/src/cli/commands/impact.ts
+++ b/ix-cli/src/cli/commands/impact.ts
@@ -12,7 +12,7 @@ export function registerImpactCommand(program: Command): void {
.description("Aggregated impact analysis — who depends on this symbol and its members")
.option("--kind <kind>", "Filter target entity by kind")
.option("--pick <n>", "Pick Nth candidate from ambiguous results (1-based)")
- .option("--depth <n>", "Expansion depth (reserved for future use)", "1")
+ .option("--depth <n>", "Expansion depth for callers/importers (default 1, max 3)", "1")
.option("--limit <n>", "Max top-impacted members to show", "10")
.option("--format <fmt>", "Output format (text|json)", "text")
.addHelpText(
@@ -26,6 +26,7 @@ export function registerImpactCommand(program: Command): void {
) => {
const client = new IxClient(getEndpoint());
const limit = parseInt(opts.limit, 10);
+ const depth = Math.min(Math.max(parseInt(opts.depth, 10) || 1, 1), 3);
const isJson = opts.format === "json";
const resolveOpts = { kind: opts.kind, pick: opts.pick ? parseInt(opts.pick, 10) : undefined };
@@ -35,9 +36,9 @@ export function registerImpactCommand(program: Command): void {
if (!isJson) printResolved(target);
if (CONTAINER_KINDS.has(target.kind)) {
- await containerImpact(client, target, limit, isJson);
+ await containerImpact(client, target, limit, depth, isJson);
} else {
- await leafImpact(client, target, isJson);
+ await leafImpact(client, target, depth, isJson);
}
}
);
@@ -47,6 +48,7 @@ async function containerImpact(
client: IxClient,
target: { id: string; kind: string; name: string; resolutionMode: string },
limit: number,
+ depth: number,
isJson: boolean
): Promise<void> {
const diagnostics: string[] = [];
@@ -54,8 +56,8 @@ async function containerImpact(
// 1. Get contained members, importers, dependents, and developer-cycle context in parallel
const [containsResult, importersResult, dependentsResult, decisionsResult, tasksResult, bugsResult] = await Promise.all([
client.expand(target.id, { direction: "out", predicates: ["CONTAINS"] }),
- client.expand(target.id, { direction: "in", predicates: ["IMPORTS"] }),
- client.expand(target.id, { direction: "in", predicates: ["CALLS", "REFERENCES"] }),
+ client.expand(target.id, { direction: "in", predicates: ["IMPORTS"], hops: depth }),
+ client.expand(target.id, { direction: "in", predicates: ["CALLS", "REFERENCES"], hops: depth }),
client.expand(target.id, { direction: "in", predicates: ["DECISION_AFFECTS"] }),
client.expand(target.id, { direction: "in", predicates: ["TASK_AFFECTS"] }),
client.expand(target.id, { direction: "in", predicates: ["BUG_AFFECTS"] }),
@@ -119,6 +121,7 @@ async function containerImpact(
resolvedTarget: { id: target.id, kind: target.kind, name: target.name },
resolutionMode: target.resolutionMode,
resultSource: "graph",
+ depth,
summary: {
members: members.length,
callers: 0,
@@ -140,11 +143,12 @@ async function containerImpact(
)
);
} else {
+ const depthNote = depth > 1 ? chalk.dim(` (depth ${depth})`) : "";
console.log(chalk.bold(`Target: ${target.kind} ${target.name}\n`));
- console.log(chalk.bold("Impact summary:"));
+ console.log(chalk.bold("Impact summary:") + depthNote);
console.log(` members: ${members.length}`);
- console.log(` direct importers: ${directImporters.length}`);
- console.log(` direct dependents: ${directDependents.length}`);
+ console.log(` importers: ${directImporters.length}`);
+ console.log(` dependents: ${directDependents.length}`);
console.log(` member-level callers: ${totalMemberCallers}`);
if (topMembers.length > 0) {
@@ -190,11 +194,12 @@ async function containerImpact(
async function leafImpact(
client: IxClient,
target: { id: string; kind: string; name: string; resolutionMode: string },
+ depth: number,
isJson: boolean
): Promise<void> {
// Fetch callers, callees, and developer-cycle context in parallel
const [callersResult, calleesResult, decisionsResult, tasksResult, bugsResult] = await Promise.all([
- client.expand(target.id, { direction: "in", predicates: ["CALLS", "REFERENCES"] }),
+ client.expand(target.id, { direction: "in", predicates: ["CALLS", "REFERENCES"], hops: depth }),
client.expand(target.id, { direction: "out", predicates: ["CALLS", "REFERENCES"] }),
client.expand(target.id, { direction: "in", predicates: ["DECISION_AFFECTS"] }),
client.expand(target.id, { direction: "in", predicates: ["TASK_AFFECTS"] }),
@@ -218,6 +223,7 @@ async function leafImpact(
resolvedTarget: { id: target.id, kind: target.kind, name: target.name },
resolutionMode: target.resolutionMode,
resultSource: "graph",
+ depth,
summary: {
members: 0,
callers: callersResult.nodes.length,
@@ -247,8 +253,9 @@ async function leafImpact(
)
);
} else {
+ const depthNote = depth > 1 ? chalk.dim(` (depth ${depth})`) : "";
console.log(chalk.bold(`Target: ${target.kind} ${target.name}\n`));
- console.log(chalk.bold("Impact summary:"));
+ console.log(chalk.bold("Impact summary:") + depthNote);
console.log(` callers: ${callersResult.nodes.length}`);
console.log(` callees: ${calleesResult.nodes.length}`);
diff --git a/ix-plugin/hooks/ix-intercept.sh b/ix-plugin/hooks/ix-intercept.sh
index 1ef04d84..2ef65369 100755
--- a/ix-plugin/hooks/ix-intercept.sh
+++ b/ix-plugin/hooks/ix-intercept.sh
@@ -17,15 +17,24 @@ TOOL=$(echo "$INPUT" | jq -r '.tool_name // empty')
# Bail silently if ix is not in PATH
command -v ix >/dev/null 2>&1 || exit 0
-# Bail silently if ix backend is not reachable
-ix status >/dev/null 2>&1 || exit 0
+# ── Health check with 30s TTL cache ─────────────────────────────────────────
+IX_HEALTH_CACHE="${TMPDIR:-/tmp}/ix-healthy"
+_now=$(date +%s)
+_cache_ok=0
+if [ -f "$IX_HEALTH_CACHE" ]; then
+ _cached=$(cat "$IX_HEALTH_CACHE" 2>/dev/null || echo 0)
+ (( (_now - _cached) < 30 )) && _cache_ok=1
+fi
+if [ "$_cache_ok" -eq 0 ]; then
+ ix status >/dev/null 2>&1 || exit 0
+ echo "$_now" > "$IX_HEALTH_CACHE"
+fi
# ── Grep: text/symbol search ─────────────────────────────────────────────────
if [ "$TOOL" = "Grep" ]; then
PATTERN=$(echo "$INPUT" | jq -r '.tool_input.pattern // empty')
[ -z "$PATTERN" ] && exit 0
- # Run ix text search (line-level matches, respects --language and --path)
PATH_ARG=$(echo "$INPUT" | jq -r '.tool_input.path // empty')
LANG_ARG=$(echo "$INPUT" | jq -r '.tool_input.type // empty')
@@ -33,10 +42,21 @@ if [ "$TOOL" = "Grep" ]; then
[ -n "$PATH_ARG" ] && TEXT_ARGS+=("--path" "$PATH_ARG")
[ -n "$LANG_ARG" ] && TEXT_ARGS+=("--language" "$LANG_ARG")
- TEXT_RESULT=$(ix text "${TEXT_ARGS[@]}" 2>/dev/null) || TEXT_RESULT=""
+ # Run ix text and ix locate in parallel
+ _text_tmp=$(mktemp)
+ _locate_tmp=$(mktemp)
+ trap 'rm -f "$_text_tmp" "$_locate_tmp"' EXIT
+
+ ix text "${TEXT_ARGS[@]}" > "$_text_tmp" 2>/dev/null &
+ _text_pid=$!
+ ix locate "$PATTERN" --limit 10 --format json > "$_locate_tmp" 2>/dev/null &
+ _locate_pid=$!
+
+ wait "$_text_pid" || true
+ wait "$_locate_pid" || true
- # Also run ix locate for symbol-level matches (class, function, etc.)
- LOCATE_RESULT=$(ix locate "$PATTERN" --limit 10 --format json 2>/dev/null) || LOCATE_RESULT=""
+ TEXT_RESULT=$(cat "$_text_tmp")
+ LOCATE_RESULT=$(cat "$_locate_tmp")
[ -z "$TEXT_RESULT" ] && [ -z "$LOCATE_RESULT" ] && exit 0
diff --git a/ix-plugin/install.sh b/ix-plugin/install.sh
new file mode 100755
index 00000000..599ca228
--- /dev/null
+++ b/ix-plugin/install.sh
@@ -0,0 +1,130 @@
+#!/usr/bin/env bash
+# ix-plugin/install.sh — Standalone Claude Code plugin installer for Ix Memory
+#
+# Usage (curl):
+# curl -fsSL https://raw.githubusercontent.com/ix-infrastructure/IX-Memory/main/ix-plugin/install.sh | bash
+#
+# Usage (local, from the IX-Memory repo):
+# bash ix-plugin/install.sh
+#
+# What it does:
+# 1. Downloads ix-intercept.sh and ix-ingest.sh to ~/.local/share/ix/plugin/hooks/
+# 2. Wires them into ~/.claude/settings.json
+#
+# Prerequisites: ix CLI must already be installed and in PATH.
+
+set -euo pipefail
+
+# ── Config ────────────────────────────────────────────────────────────────────
+
+GITHUB_RAW="https://raw.githubusercontent.com/ix-infrastructure/IX-Memory/main/ix-plugin/hooks"
+INSTALL_DIR="${IX_PLUGIN_DIR:-$HOME/.local/share/ix/plugin/hooks}"
+SETTINGS="$HOME/.claude/settings.json"
+
+# ── Helpers ───────────────────────────────────────────────────────────────────
+
+info() { echo " [ok] $*"; }
+warn() { echo " [!!] $*" >&2; }
+die() { echo " [error] $*" >&2; exit 1; }
+
+# ── Dependency check ──────────────────────────────────────────────────────────
+
+echo ""
+echo "╔══════════════════════════════════════════╗"
+echo "║ Ix Memory — Claude Code plugin ║"
+echo "╚══════════════════════════════════════════╝"
+echo ""
+echo "── Checking dependencies ──"
+
+for dep in jq curl; do
+ command -v "$dep" >/dev/null 2>&1 || die "Required tool not found: $dep"
+done
+info "curl, jq"
+
+if ! command -v ix >/dev/null 2>&1; then
+ warn "'ix' not found in PATH — hooks will be installed but won't activate until ix is installed."
+ warn "Install ix first: see https://github.com/ix-infrastructure/IX-Memory"
+fi
+
+# ── Download hooks ────────────────────────────────────────────────────────────
+
+echo ""
+echo "── Downloading hooks ──"
+
+mkdir -p "$INSTALL_DIR"
+
+# Detect if we're running from the repo (local install) vs. curl
+_repo_hooks=""
+if [ -n "${BASH_SOURCE[0]:-}" ] && [ "${BASH_SOURCE[0]}" != "bash" ]; then
+ _script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)"
+ # Hooks live in hooks/ subdir relative to this script
+ if [ -f "$_script_dir/hooks/ix-intercept.sh" ]; then
+ _repo_hooks="$_script_dir/hooks"
+ fi
+fi
+
+if [ -n "$_repo_hooks" ]; then
+ # Local install — copy from repo
+ cp "$_repo_hooks/ix-intercept.sh" "$INSTALL_DIR/ix-intercept.sh"
+ cp "$_repo_hooks/ix-ingest.sh" "$INSTALL_DIR/ix-ingest.sh"
+ info "Copied hooks from local repo → $INSTALL_DIR"
+else
+ # Remote install — download from GitHub
+ curl -fsSL "$GITHUB_RAW/ix-intercept.sh" -o "$INSTALL_DIR/ix-intercept.sh"
+ curl -fsSL "$GITHUB_RAW/ix-ingest.sh" -o "$INSTALL_DIR/ix-ingest.sh"
+ info "Downloaded hooks → $INSTALL_DIR"
+fi
+
+chmod +x "$INSTALL_DIR/ix-intercept.sh" "$INSTALL_DIR/ix-ingest.sh"
+info "Permissions set"
+
+# ── Wire Claude Code settings ─────────────────────────────────────────────────
+
+echo ""
+echo "── Configuring Claude Code ──"
+
+INTERCEPT="$INSTALL_DIR/ix-intercept.sh"
+INGEST="$INSTALL_DIR/ix-ingest.sh"
+
+mkdir -p "$HOME/.claude"
+[ -f "$SETTINGS" ] || echo "{}" > "$SETTINGS"
+
+# Idempotent: skip if already wired
+already=$(jq --arg cmd "$INTERCEPT" \
+ '[.hooks?.PreToolUse[]?.hooks[]?.command? // empty] | map(select(. == $cmd)) | length' \
+ "$SETTINGS" 2>/dev/null || echo "0")
+
+if [ "$already" -gt 0 ]; then
+ info "Hooks already registered in ~/.claude/settings.json — skipping"
+else
+ tmp=$(mktemp)
+ jq --arg intercept "$INTERCEPT" --arg ingest "$INGEST" '
+ .hooks |= (. // {}) |
+ .hooks.PreToolUse |= (. // []) |
+ .hooks.PreToolUse += [{
+ "matcher": "Grep|Glob",
+ "hooks": [{ "type": "command", "command": $intercept, "timeout": 10 }]
+ }] |
+ .hooks.PostToolUse |= (. // []) |
+ .hooks.PostToolUse += [{
+ "matcher": "Write|Edit|MultiEdit",
+ "hooks": [{ "type": "command", "command": $ingest, "timeout": 30 }]
+ }]
+ ' "$SETTINGS" > "$tmp" && mv "$tmp" "$SETTINGS"
+ info "Registered hooks → ~/.claude/settings.json"
+fi
+
+# ── Done ──────────────────────────────────────────────────────────────────────
+
+echo ""
+echo "╔══════════════════════════════════════════╗"
+echo "║ Ix Claude plugin installed! ║"
+echo "╚══════════════════════════════════════════╝"
+echo ""
+echo " Hooks installed to: $INSTALL_DIR"
+echo ""
+echo " Restart Claude Code to activate."
+echo ""
+echo " To uninstall:"
+echo " curl -fsSL https://raw.githubusercontent.com/ix-infrastructure/IX-Memory/main/ix-plugin/uninstall.sh | bash"
+echo ""
diff --git a/ix-plugin/uninstall.sh b/ix-plugin/uninstall.sh
new file mode 100755
index 00000000..ff105535
--- /dev/null
+++ b/ix-plugin/uninstall.sh
@@ -0,0 +1,54 @@
+#!/usr/bin/env bash
+# ix-plugin/uninstall.sh — Remove the Ix Memory Claude Code plugin
+#
+# Usage (curl):
+# curl -fsSL https://raw.githubusercontent.com/ix-infrastructure/IX-Memory/main/ix-plugin/uninstall.sh | bash
+#
+# Usage (local):
+# bash ix-plugin/uninstall.sh
+
+set -euo pipefail
+
+INSTALL_DIR="${IX_PLUGIN_DIR:-$HOME/.local/share/ix/plugin/hooks}"
+SETTINGS="$HOME/.claude/settings.json"
+
+info() { echo " [ok] $*"; }
+
+echo ""
+echo "── Removing Ix Claude Code plugin ──"
+
+# Remove hook files
+if [ -d "$INSTALL_DIR" ]; then
+ rm -f "$INSTALL_DIR/ix-intercept.sh" "$INSTALL_DIR/ix-ingest.sh"
+ rmdir "$INSTALL_DIR" 2>/dev/null || true
+ info "Removed $INSTALL_DIR"
+else
+ echo " (hooks directory not found — nothing to remove)"
+fi
+
+# Remove hook entries from ~/.claude/settings.json
+if [ -f "$SETTINGS" ] && command -v jq >/dev/null 2>&1; then
+ INTERCEPT="$INSTALL_DIR/ix-intercept.sh"
+ INGEST="$INSTALL_DIR/ix-ingest.sh"
+
+ tmp=$(mktemp)
+ jq --arg intercept "$INTERCEPT" --arg ingest "$INGEST" '
+ if .hooks.PreToolUse then
+ .hooks.PreToolUse |= map(select(
+ (.hooks // []) | map(.command) | any(. == $intercept) | not
+ ))
+ else . end |
+ if .hooks.PostToolUse then
+ .hooks.PostToolUse |= map(select(
+ (.hooks // []) | map(.command) | any(. == $ingest) | not
+ ))
+ else . end
+ ' "$SETTINGS" > "$tmp" && mv "$tmp" "$SETTINGS"
+ info "Removed hooks from ~/.claude/settings.json"
+else
+ echo " (settings.json not found — nothing to remove)"
+fi
+
+echo ""
+echo " Done. Restart Claude Code to deactivate."
+echo ""
diff --git a/memory-layer/src/main/scala/ix/memory/context/ClaimCollector.scala b/memory-layer/src/main/scala/ix/memory/context/ClaimCollector.scala
index cc2f696d..9d5c0a87 100644
--- a/memory-layer/src/main/scala/ix/memory/context/ClaimCollector.scala
+++ b/memory-layer/src/main/scala/ix/memory/context/ClaimCollector.scala
@@ -1,7 +1,6 @@
package ix.memory.context
import cats.effect.IO
-import cats.syntax.parallel._
import ix.memory.db.GraphQueryApi
import ix.memory.model._
@@ -9,7 +8,5 @@ import ix.memory.model._
class ClaimCollector(queryApi: GraphQueryApi) {
def collect(nodeIds: Vector[NodeId]): IO[Vector[Claim]] =
- nodeIds
- .parTraverse(id => queryApi.getClaims(id))
- .map(_.flatten.distinctBy(_.id))
+ queryApi.getClaimsBatch(nodeIds).map(_.distinctBy(_.id))
}
diff --git a/memory-layer/src/main/scala/ix/memory/db/ArangoGraphQueryApi.scala b/memory-layer/src/main/scala/ix/memory/db/ArangoGraphQueryApi.scala
index 1d3aee1c..4e641545 100644
--- a/memory-layer/src/main/scala/ix/memory/db/ArangoGraphQueryApi.scala
+++ b/memory-layer/src/main/scala/ix/memory/db/ArangoGraphQueryApi.scala
@@ -282,6 +282,20 @@ class ArangoGraphQueryApi(client: ArangoClient) extends GraphQueryApi {
)
).map(_.flatMap(parseClaim).toVector)
+ override def getClaimsBatch(entityIds: Seq[NodeId]): IO[Vector[Claim]] =
+ if (entityIds.isEmpty) IO.pure(Vector.empty)
+ else {
+ val idList = new java.util.ArrayList[String](entityIds.size)
+ entityIds.foreach(id => idList.add(id.value.toString))
+ client.query(
+ """FOR c IN claims
+ | FILTER c.entity_id IN @ids
+ | AND c.deleted_rev == null
+ | RETURN c""".stripMargin,
+ Map("ids" -> idList.asInstanceOf[AnyRef])
+ ).map(_.flatMap(parseClaim).toVector)
+ }
+
override def getLatestRev: IO[Rev] =
client.queryOne(
"""FOR r IN revisions
@@ -320,25 +334,45 @@ class ArangoGraphQueryApi(client: ArangoClient) extends GraphQueryApi {
).map(_.toVector)
override def getChangedEntities(fromRev: Rev, toRev: Rev): IO[Vector[(GraphNode, Option[GraphNode])]] = {
- val changedIdsAql = """
+ val aql = """
FOR n IN nodes
FILTER n.created_rev > @fromRev AND n.created_rev <= @toRev
COLLECT logicalId = n.logical_id
- RETURN logicalId
+ LET atFrom = FIRST(
+ FOR x IN nodes
+ FILTER x.logical_id == logicalId
+ AND x.created_rev <= @fromRev
+ AND (x.deleted_rev == null OR @fromRev < x.deleted_rev)
+ SORT x.created_rev DESC
+ LIMIT 1
+ RETURN x
+ )
+ LET atTo = FIRST(
+ FOR x IN nodes
+ FILTER x.logical_id == logicalId
+ AND x.created_rev <= @toRev
+ AND (x.deleted_rev == null OR @toRev < x.deleted_rev)
+ SORT x.created_rev DESC
+ LIMIT 1
+ RETURN x
+ )
+ FILTER atTo != null
+ RETURN { atFrom: atFrom, atTo: atTo }
"""
- for {
- logicalIds <- client.query(changedIdsAql, Map(
- "fromRev" -> Long.box(fromRev.value).asInstanceOf[AnyRef],
- "toRev" -> Long.box(toRev.value).asInstanceOf[AnyRef]
- )).map(_.flatMap(_.asString).toVector)
- results <- logicalIds.traverse { lid =>
- val nodeId = NodeId(java.util.UUID.fromString(lid))
+ client.query(aql, Map(
+ "fromRev" -> Long.box(fromRev.value).asInstanceOf[AnyRef],
+ "toRev" -> Long.box(toRev.value).asInstanceOf[AnyRef]
+ )).map { results =>
+ results.flatMap { json =>
+ val c = json.hcursor
for {
- atFrom <- getNode(nodeId, asOfRev = Some(fromRev))
- atTo <- getNode(nodeId, asOfRev = Some(toRev))
- } yield atTo.map(to => (to, atFrom))
- }
- } yield results.flatten
+ atTo <- c.downField("atTo").focus.flatMap(parseNode)
+ } yield {
+ val atFrom = c.downField("atFrom").focus.flatMap(parseNode)
+ (atTo, atFrom)
+ }
+ }.toVector
+ }
}
override def getDiffSummary(fromRev: Rev, toRev: Rev): IO[Map[String, Int]] = {
@@ -434,7 +468,8 @@ class ArangoGraphQueryApi(client: ArangoClient) extends GraphQueryApi {
case Direction.Both => "FILTER e.src IN target_ids OR e.dst IN target_ids"
}
- val aql =
+ // Phase 1: fetch edges only (no correlated node subquery per row)
+ val edgeAql =
s"""LET target_ids = (
| FOR n IN nodes
| FILTER n.name == @name AND n.deleted_rev == null
@@ -445,16 +480,7 @@ class ArangoGraphQueryApi(client: ArangoClient) extends GraphQueryApi {
| 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
+ | RETURN MERGE(e, { _target_ids: target_ids })""".stripMargin
val binds = scala.collection.mutable.Map[String, AnyRef](
"name" -> name.asInstanceOf[AnyRef]
@@ -470,15 +496,36 @@ class ArangoGraphQueryApi(client: ArangoClient) extends GraphQueryApi {
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)
- }
+ for {
+ edgeRows <- client.query(edgeAql, binds.toMap)
+ allEdges = edgeRows.flatMap(parseEdge).toVector
+
+ // Determine which side is the "other" node by checking if src was a target
+ targetIdSet: Set[String] = edgeRows.headOption
+ .flatMap(_.hcursor.downField("_target_ids").as[List[String]].toOption)
+ .getOrElse(Nil).toSet
+
+ neighborIds = allEdges.flatMap { e =>
+ if (targetIdSet.contains(e.src.value.toString)) Vector(e.dst)
+ else if (targetIdSet.contains(e.dst.value.toString)) Vector(e.src)
+ else Vector(e.src, e.dst)
+ }.distinct
+
+ // Phase 2: batch-fetch all neighbor nodes in one query
+ nodes <- if (neighborIds.isEmpty) IO.pure(Vector.empty[GraphNode])
+ else {
+ val idList = new java.util.ArrayList[String](neighborIds.size)
+ neighborIds.foreach(nid => idList.add(nid.value.toString))
+ client.query(
+ """FOR n IN nodes
+ | FILTER n.logical_id IN @ids AND n.deleted_rev == null
+ | SORT n.logical_id, n.created_rev DESC
+ | COLLECT lid = n.logical_id INTO grp
+ | RETURN FIRST(grp).n""".stripMargin,
+ Map("ids" -> idList.asInstanceOf[AnyRef])
+ ).map(_.flatMap(parseNode).toVector)
+ }
+ } yield ExpandResult(nodes, allEdges)
}
// ── JSON Parsers (snake_case → camelCase) ───────────────────────────
diff --git a/memory-layer/src/main/scala/ix/memory/db/GraphQueryApi.scala b/memory-layer/src/main/scala/ix/memory/db/GraphQueryApi.scala
index 7be285f8..c5f1b84e 100644
--- a/memory-layer/src/main/scala/ix/memory/db/GraphQueryApi.scala
+++ b/memory-layer/src/main/scala/ix/memory/db/GraphQueryApi.scala
@@ -16,6 +16,7 @@ trait GraphQueryApi {
predicates: Option[Set[String]] = None, hops: Int = 1,
asOfRev: Option[Rev] = None): IO[ExpandResult]
def getClaims(entityId: NodeId): IO[Vector[Claim]]
+ def getClaimsBatch(entityIds: Seq[NodeId]): IO[Vector[Claim]]
def getLatestRev: IO[Rev]
def getPatchesForEntity(entityId: NodeId): IO[List[Json]]
def getPatchesBySource(sourceUri: String, extractor: String): IO[Vector[Json]]
diff --git a/setup.sh b/setup.sh
index aff47366..54e204bf 100755
--- a/setup.sh
+++ b/setup.sh
@@ -47,45 +47,9 @@ ensure_local_bin_on_path() {
}
install_claude_hooks() {
- local settings="$HOME/.claude/settings.json"
- local intercept="$IX_DIR/ix-plugin/hooks/ix-intercept.sh"
- local ingest="$IX_DIR/ix-plugin/hooks/ix-ingest.sh"
-
- chmod +x "$intercept" "$ingest"
-
- mkdir -p "$HOME/.claude"
- [ -f "$settings" ] || echo "{}" > "$settings"
-
- # Merge hooks into existing settings without clobbering other keys.
- # If the ix hooks are already present (matched by command path), skip.
- local already
- already=$(jq --arg cmd "$intercept" \
- '[.hooks?.PreToolUse[]?.hooks[]?.command? // empty] | map(select(. == $cmd)) | length' \
- "$settings" 2>/dev/null || echo "0")
-
- if [ "$already" -gt 0 ]; then
- echo " [ok] Claude Code hooks already configured — skipping"
- return
- fi
-
- local tmp
- tmp=$(mktemp)
- jq --arg intercept "$intercept" --arg ingest "$ingest" '
- .hooks |= (. // {}) |
- .hooks.PreToolUse |= (. // []) |
- .hooks.PreToolUse += [{
- "matcher": "Grep|Glob",
- "hooks": [{ "type": "command", "command": $intercept, "timeout": 10 }]
- }] |
- .hooks.PostToolUse |= (. // []) |
- .hooks.PostToolUse += [{
- "matcher": "Write|Edit|MultiEdit",
- "hooks": [{ "type": "command", "command": $ingest, "timeout": 30 }]
- }]
- ' "$settings" > "$tmp" && mv "$tmp" "$settings"
-
- echo " [ok] Claude Code hooks installed → ~/.claude/settings.json"
- echo " Restart Claude Code to activate."
+ # Delegate to the standalone installer — keeps curl and repo installs in sync.
+ # Hooks are copied to ~/.local/share/ix/plugin/hooks (not repo-relative).
+ bash "$IX_DIR/ix-plugin/install.sh"
}
install_global_ix() {