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
adding startup and shutdown scripts
riley0227590730349c65
diff --git a/.claude/settings.json b/.claude/settings.jsonnew file mode 100644index 00000000..b6637478--- /dev/null+++ b/.claude/settings.json@@ -0,0 +1,14 @@+{+ "mcpServers": {+ "ix-memory": {+ "command": "npx",+ "args": [+ "tsx",+ "/Users/rileythompson/startprojes/startup/IX-Memory/ix-cli/src/mcp/server.ts"+ ],+ "env": {+ "IX_ENDPOINT": "http://localhost:8090"+ }+ }+ }+}diff --git a/.mcp.json b/.mcp.jsonnew file mode 100644index 00000000..1181fc20--- /dev/null+++ b/.mcp.json@@ -0,0 +1,15 @@+{+ "mcpServers": {+ "ix-memory": {+ "type": "stdio",+ "command": "npx",+ "args": [+ "tsx",+ "/Users/rileythompson/startprojes/startup/IX-Memory/ix-cli/src/mcp/server.ts"+ ],+ "env": {+ "IX_ENDPOINT": "http://localhost:8090"+ }+ }+ }+}diff --git a/CLAUDE.md b/CLAUDE.mdnew file mode 100644index 00000000..e72bf14c--- /dev/null+++ b/CLAUDE.md@@ -0,0 +1,34 @@+<!-- IX-MEMORY START -->+# Ix Memory System++This project uses Ix Memory — persistent, time-aware context for LLM assistants.++## MANDATORY RULES+1. BEFORE answering any question about the codebase → call `ix_query` first. Do NOT answer from training data alone.+2. AFTER every design or architecture decision → call `ix_decide` with both the conclusion AND the reasoning.+3. When you notice contradictory information → call `ix_conflicts` and present conflicts to the user before continuing.+4. NEVER guess about codebase facts — if Ix has structured data, use it. Say "according to Ix" when citing results.+5. IMMEDIATELY after modifying code → call `ix_ingest` on changed files. Do not batch this to the end of the session.+6. At start of each session → review `ix://session/context` to load prior work and decisions.+7. When the user states a goal → call `ix_truth` to record the intent so all decisions can trace back to it.++## Workflow+A typical session follows this flow:+1. **Start** — Read `ix://session/context` and `ix://project/intent` to understand prior state.+2. **Query** — Before any task, call `ix_query` to get relevant context from the knowledge graph.+3. **Work** — Implement changes, making decisions as needed.+4. **Ingest** — After each file change, call `ix_ingest` immediately to keep the graph current.+5. **Decide** — Record any design decisions with `ix_decide` so future sessions can understand why.++## What NOT to Do+- Do NOT answer architecture questions from training data alone — always check Ix first.+- Do NOT skip `ix_ingest` after modifying files — stale memory leads to wrong answers next session.+- Do NOT record a decision without rationale — "we chose X" is useless without "because Y".+- Do NOT ignore conflicts — if `ix_conflicts` returns results, surface them to the user before proceeding.++## Confidence Scores+Ix returns confidence scores with query results. When data has low confidence:+- Mention the uncertainty to the user (e.g., "Ix has low confidence on this — it may be outdated").+- Suggest re-ingesting the relevant files to improve confidence.+- Never present low-confidence data as established fact.+<!-- IX-MEMORY END -->diff --git a/docker-compose.yml b/docker-compose.ymlindex 7e829dbe..b2ec0ba9 100644--- a/docker-compose.yml+++ b/docker-compose.yml@@ -18,6 +18,8 @@ services:build: ./memory-layerports:- "8090:8090"+ volumes:+ - ${HOME}:${HOME}:roenvironment:ARANGO_HOST: arangodbARANGO_PORT: "8529"diff --git a/ix-cli/src/cli/__tests__/init.test.ts b/ix-cli/src/cli/__tests__/init.test.tsindex f220afeb..84bc63af 100644--- a/ix-cli/src/cli/__tests__/init.test.ts+++ b/ix-cli/src/cli/__tests__/init.test.ts@@ -15,7 +15,7 @@ let CLAUDE_MD: string;beforeAll(async () => {const mod = await import("../commands/init.js");- CLAUDE_MD = mod.CLAUDE_MD;+ CLAUDE_MD = mod.IX_CLAUDE_MD_BLOCK;});describe("CLAUDE_MD template", () => {diff --git a/ix-cli/src/cli/commands/init.ts b/ix-cli/src/cli/commands/init.tsindex 68b15be3..ee6e2de1 100644--- a/ix-cli/src/cli/commands/init.ts+++ b/ix-cli/src/cli/commands/init.ts@@ -6,7 +6,11 @@ import type { Command } from "commander";import { IxClient } from "../../client/api.js";import { getEndpoint } from "../config.js";-export const CLAUDE_MD = `# Ix Memory System+export const IX_MARKER_START = "<!-- IX-MEMORY START -->";+export const IX_MARKER_END = "<!-- IX-MEMORY END -->";++export const IX_CLAUDE_MD_BLOCK = `${IX_MARKER_START}+# Ix Memory SystemThis project uses Ix Memory — persistent, time-aware context for LLM assistants.@@ -38,7 +42,7 @@ Ix returns confidence scores with query results. When data has low confidence:- Mention the uncertainty to the user (e.g., "Ix has low confidence on this — it may be outdated").- Suggest re-ingesting the relevant files to improve confidence.- Never present low-confidence data as established fact.-`;+${IX_MARKER_END}`;export function registerInitCommand(program: Command): void {program@@ -68,19 +72,26 @@ export function registerInitCommand(program: Command): void {);console.log(" [ok] Created ~/.ix/config.yaml");- // 3. Create CLAUDE.md in project root (don't overwrite without --force)- if (existsSync("CLAUDE.md") && !opts.force) {+ // 3. Add IX block to CLAUDE.md (using markers for clean add/remove)+ if (existsSync("CLAUDE.md")) {const existing = await readFile("CLAUDE.md", "utf-8");- if (existing.includes("ix_query") || existing.includes("Ix Memory")) {- console.log(" [ok] CLAUDE.md already contains Ix rules (use --force to overwrite)");+ if (existing.includes(IX_MARKER_START)) {+ if (opts.force) {+ // Replace existing IX block+ const re = new RegExp(`${IX_MARKER_START}[\\s\\S]*?${IX_MARKER_END}`, "g");+ await writeFile("CLAUDE.md", existing.replace(re, IX_CLAUDE_MD_BLOCK));+ console.log(" [ok] Updated Ix rules in CLAUDE.md");+ } else {+ console.log(" [ok] CLAUDE.md already contains Ix rules (use --force to replace)");+ }} else {- // Append Ix rules to existing CLAUDE.md- await writeFile("CLAUDE.md", existing + "\n\n" + CLAUDE_MD);- console.log(" [ok] Appended Ix rules to existing CLAUDE.md");+ // Append IX block to existing CLAUDE.md+ await writeFile("CLAUDE.md", existing.trimEnd() + "\n\n" + IX_CLAUDE_MD_BLOCK + "\n");+ console.log(" [ok] Appended Ix rules to CLAUDE.md");}} else {- await writeFile("CLAUDE.md", CLAUDE_MD);- console.log(" [ok] Created CLAUDE.md");+ await writeFile("CLAUDE.md", IX_CLAUDE_MD_BLOCK + "\n");+ console.log(" [ok] Created CLAUDE.md with Ix rules");}console.log("\nIx Memory initialized.");diff --git a/ix-cli/src/cli/commands/mcp-install.ts b/ix-cli/src/cli/commands/mcp-install.tsindex e7d11d9c..87475591 100644--- a/ix-cli/src/cli/commands/mcp-install.ts+++ b/ix-cli/src/cli/commands/mcp-install.ts@@ -6,6 +6,7 @@ import type { Command } from "commander";interface McpConfig {mcpServers: Record<string, {+ type?: string;command: string;args: string[];env?: Record<string, string>;@@ -16,6 +17,7 @@ interface McpConfig {const serverPath = join(new URL(".", import.meta.url).pathname, "../../mcp/server.ts");const ixMcpEntry = {+ type: "stdio",command: "npx",args: ["tsx", serverPath],env: {@@ -71,13 +73,14 @@ async function installCursor(): Promise<void> {}async function installClaudeCode(): Promise<void> {- const configPath = join(process.cwd(), ".claude", "settings.json");+ // Claude Code reads MCP config from .mcp.json in the project root+ const configPath = join(process.cwd(), ".mcp.json");const config = await loadOrCreateConfig(configPath);config.mcpServers["ix-memory"] = ixMcpEntry;- await mkdir(join(configPath, ".."), { recursive: true });await writeFile(configPath, JSON.stringify(config, null, 2) + "\n");console.log(` [ok] Installed Ix MCP server in Claude Code config`);console.log(` ${configPath}`);+ console.log(" Restart Claude Code to activate.");}async function loadOrCreateConfig(path: string): Promise<McpConfig> {diff --git a/package-lock.json b/package-lock.jsonnew file mode 100644index 00000000..836a1a1f--- /dev/null+++ b/package-lock.json@@ -0,0 +1,6 @@+{+ "name": "IX-Memory",+ "lockfileVersion": 3,+ "requires": true,+ "packages": {}+}diff --git a/scripts/backend.sh b/scripts/backend.shnew file mode 100755index 00000000..d15147bc--- /dev/null+++ b/scripts/backend.sh@@ -0,0 +1,211 @@+#!/usr/bin/env bash+set -euo pipefail++# ─────────────────────────────────────────────────────────────────────────────+# IX-Memory — Backend Setup+#+# Builds the Memory Layer JAR (if needed) and starts ArangoDB + Memory Layer+# via Docker Compose.+#+# Usage:+# ./scripts/backend.sh # Start backend (default)+# ./scripts/backend.sh up # Start backend+# ./scripts/backend.sh down # Stop backend+# ./scripts/backend.sh status # Show service status+# ./scripts/backend.sh logs # Tail service logs+# ./scripts/backend.sh clean # Stop + remove data volumes+# ./scripts/backend.sh rebuild # Force rebuild JAR + restart+# ./scripts/backend.sh check # Just check if backend is healthy+# ─────────────────────────────────────────────────────────────────────────────++IX_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"+cd "$IX_DIR"++JAR_PATH="memory-layer/target/scala-2.13/ix-memory-layer.jar"+HEALTH_URL="http://localhost:8090/v1/health"+ARANGO_URL="http://localhost:8529/_api/version"++# ── Helpers ──────────────────────────────────────────────────────────────────++ensure_docker() {+ if ! command -v docker &> /dev/null; then+ echo "Error: Docker is not installed."+ echo " Install: https://docs.docker.com/get-docker/"+ exit 1+ fi++ if docker info &> /dev/null 2>&1; then+ echo "[ok] Docker is running"+ return 0+ fi++ # Docker is installed but not running — try to start it+ echo "Docker is not running. Attempting to start..."++ if [ "$(uname)" = "Darwin" ]; then+ # macOS: try Docker Desktop+ if [ -d "/Applications/Docker.app" ]; then+ open -a Docker+ echo " Launched Docker Desktop, waiting for it to start..."+ elif command -v colima &> /dev/null; then+ colima start+ echo " Started Colima..."+ else+ echo "Error: Cannot find Docker Desktop or Colima to start."+ echo " Start Docker manually and try again."+ exit 1+ fi+ elif [ "$(uname)" = "Linux" ]; then+ # Linux: try systemctl+ if command -v systemctl &> /dev/null; then+ echo " Running: sudo systemctl start docker"+ sudo systemctl start docker+ else+ echo "Error: Cannot auto-start Docker on this system."+ echo " Start Docker manually and try again."+ exit 1+ fi+ else+ echo "Error: Cannot auto-start Docker on this platform."+ echo " Start Docker manually and try again."+ exit 1+ fi++ # Wait for Docker to be ready+ for i in $(seq 1 30); do+ if docker info &> /dev/null 2>&1; then+ echo "[ok] Docker is now running"+ return 0+ fi+ printf "."+ sleep 2+ done++ echo ""+ echo "Error: Docker did not start within 60 seconds."+ echo " Start Docker manually and try again."+ exit 1+}++build_jar() {+ local force="${1:-false}"+ if [ "$force" = "true" ] || [ ! -f "$JAR_PATH" ]; then+ if ! command -v sbt &> /dev/null; then+ echo "Error: sbt is not installed."+ echo " Install: https://www.scala-sbt.org/download.html"+ exit 1+ fi+ echo "Building Memory Layer JAR..."+ sbt "memoryLayer/assembly" 2>&1 | tail -5+ echo "[ok] JAR built: $JAR_PATH"+ else+ echo "[ok] JAR already exists (use 'rebuild' to force)"+ fi+}++wait_for_health() {+ echo "Waiting for services to become healthy..."+ for i in $(seq 1 30); do+ if curl -sf "$HEALTH_URL" > /dev/null 2>&1; then+ echo ""+ echo "[ok] Backend is ready!"+ echo " Memory Layer: http://localhost:8090"+ echo " ArangoDB: http://localhost:8529"+ return 0+ fi+ printf "."+ sleep 2+ done+ echo ""+ echo "[!!] Health check timed out after 60 seconds."+ echo " Check logs: ./scripts/backend.sh logs"+ return 1+}++is_healthy() {+ curl -sf "$HEALTH_URL" > /dev/null 2>&1+}++containers_running() {+ # Check if both containers are running via docker compose+ local running+ running=$(docker compose ps --status running --format json 2>/dev/null | wc -l)+ [ "$running" -ge 2 ]+}++# ── Commands ─────────────────────────────────────────────────────────────────++case "${1:-up}" in+ up)+ # If backend is already healthy, skip everything+ if is_healthy; then+ echo "[ok] Backend is already running and healthy"+ echo " Memory Layer: http://localhost:8090"+ echo " ArangoDB: http://localhost:8529"+ exit 0+ fi++ ensure_docker+ build_jar++ # If containers are running but not healthy, restart them+ if containers_running; then+ echo "Containers are running but not healthy — restarting..."+ docker compose restart+ else+ echo "Starting backend services..."+ docker compose up -d --build+ fi++ wait_for_health+ ;;+ down)+ docker compose down+ echo "[ok] Backend stopped."+ ;;+ status)+ docker compose ps+ echo ""+ if is_healthy; then+ echo "[ok] Backend is healthy"+ else+ echo "[!!] Backend is not responding"+ fi+ ;;+ logs)+ docker compose logs -f+ ;;+ clean)+ docker compose down -v+ echo "[ok] Backend stopped and data volumes removed."+ ;;+ rebuild)+ ensure_docker+ build_jar true+ echo "Rebuilding and starting backend..."+ docker compose up -d --build+ wait_for_health+ ;;+ check)+ if is_healthy; then+ echo "[ok] Backend is healthy at $HEALTH_URL"+ exit 0+ else+ echo "[!!] Backend is not responding at $HEALTH_URL"+ exit 1+ fi+ ;;+ *)+ echo "Usage: ./scripts/backend.sh [COMMAND]"+ echo ""+ echo "Commands:"+ echo " up Build JAR (if needed) and start services (default)"+ echo " down Stop all services"+ echo " status Show service status and health"+ echo " logs Tail service logs"+ echo " clean Stop services and remove data volumes"+ echo " rebuild Force rebuild JAR and restart services"+ echo " check Check if backend is healthy (exit 0/1)"+ exit 1+ ;;+esacdiff --git a/scripts/build-cli.sh b/scripts/build-cli.shnew file mode 100755index 00000000..c9615c59--- /dev/null+++ b/scripts/build-cli.sh@@ -0,0 +1,97 @@+#!/usr/bin/env bash+set -euo pipefail++# ─────────────────────────────────────────────────────────────────────────────+# IX-Memory — Build CLI+#+# Installs dependencies and compiles the TypeScript CLI + MCP server.+#+# Usage:+# ./scripts/build-cli.sh # Install deps + build+# ./scripts/build-cli.sh --clean # Remove node_modules + dist, then rebuild+# ./scripts/build-cli.sh --check # Just verify CLI is built and working+# ─────────────────────────────────────────────────────────────────────────────++IX_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"+CLI_DIR="$IX_DIR/ix-cli"++# ── Preflight ────────────────────────────────────────────────────────────────++check_prerequisites() {+ if ! command -v node &> /dev/null; then+ echo "Error: Node.js is not installed."+ echo " Install: https://nodejs.org/ (v18+ required)"+ exit 1+ fi++ NODE_VERSION=$(node -v | sed 's/v//' | cut -d. -f1)+ if [ "$NODE_VERSION" -lt 18 ]; then+ echo "Error: Node.js 18+ required (found $(node -v))"+ exit 1+ fi++ if ! command -v npm &> /dev/null; then+ echo "Error: npm is not installed."+ exit 1+ fi+}++# ── Commands ─────────────────────────────────────────────────────────────────++case "${1:---build}" in+ --clean)+ check_prerequisites+ echo "Cleaning CLI build artifacts..."+ rm -rf "$CLI_DIR/node_modules" "$CLI_DIR/dist"+ echo "[ok] Cleaned"++ echo "Installing dependencies..."+ cd "$CLI_DIR"+ npm install --silent+ echo "[ok] Dependencies installed"++ echo "Building CLI..."+ npm run build+ echo "[ok] CLI built: $CLI_DIR/dist/"+ ;;++ --check)+ if [ ! -d "$CLI_DIR/dist" ]; then+ echo "[!!] CLI is not built. Run: ./scripts/build-cli.sh"+ exit 1+ fi+ if [ ! -d "$CLI_DIR/node_modules" ]; then+ echo "[!!] Dependencies not installed. Run: ./scripts/build-cli.sh"+ exit 1+ fi+ echo "[ok] CLI is built at $CLI_DIR/dist/"+ ;;++ --build|*)+ # Skip if already built and node_modules exist+ if [ -d "$CLI_DIR/dist" ] && [ -d "$CLI_DIR/node_modules" ]; then+ echo "[ok] CLI is already built (use --clean to force rebuild)"+ exit 0+ fi++ check_prerequisites++ if [ ! -d "$CLI_DIR/node_modules" ]; then+ echo "Installing dependencies..."+ cd "$CLI_DIR"+ npm install --silent+ echo "[ok] Dependencies installed"+ else+ echo "[ok] Dependencies already installed"+ cd "$CLI_DIR"+ fi++ echo "Building CLI..."+ npm run build+ echo "[ok] CLI built: $CLI_DIR/dist/"++ echo ""+ echo "Run the CLI with:"+ echo " npx --prefix $CLI_DIR tsx $CLI_DIR/src/cli/main.ts status"+ ;;+esacdiff --git a/scripts/connect.sh b/scripts/connect.shnew file mode 100755index 00000000..4df970fe--- /dev/null+++ b/scripts/connect.sh@@ -0,0 +1,163 @@+#!/usr/bin/env bash+set -euo pipefail++# ─────────────────────────────────────────────────────────────────────────────+# IX-Memory — Connect a Project+#+# Connects a project to IX-Memory:+# 1. Creates .mcp.json in the project (so Claude Code sees IX tools)+# 2. Adds IX rules to CLAUDE.md (so Claude follows the IX workflow)+# 3. Ingests the project's source code into the knowledge graph+#+# Usage:+# ./scripts/connect.sh ~/my-project # Claude Code (default)+# ./scripts/connect.sh ~/my-project --cursor # Cursor+# ./scripts/connect.sh ~/my-project --claude-desktop # Claude Desktop+# ./scripts/connect.sh ~/my-project --skip-ingest # Don't ingest yet+# ─────────────────────────────────────────────────────────────────────────────++IX_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"+CLI_DIR="$IX_DIR/ix-cli"+IX_CMD="npx --prefix $CLI_DIR tsx $CLI_DIR/src/cli/main.ts"++# ── Parse arguments ──────────────────────────────────────────────────────────++PROJECT_DIR=""+IDE="claude-code"+SKIP_INGEST=false++while [[ $# -gt 0 ]]; do+ case "$1" in+ --claude-desktop) IDE="claude-desktop"; shift ;;+ --cursor) IDE="cursor"; shift ;;+ --claude-code) IDE="claude-code"; shift ;;+ --skip-ingest) SKIP_INGEST=true; shift ;;+ -h|--help)+ echo "Usage: ./scripts/connect.sh <PROJECT_DIR> [OPTIONS]"+ echo ""+ echo "Connects a project to IX-Memory so Claude can use the knowledge graph."+ echo ""+ echo "Arguments:"+ echo " PROJECT_DIR Path to the project to connect (required)"+ echo ""+ echo "Options:"+ echo " --claude-code Install MCP for Claude Code (default)"+ echo " --claude-desktop Install MCP for Claude Desktop"+ echo " --cursor Install MCP for Cursor"+ echo " --skip-ingest Don't ingest the codebase yet"+ echo " -h, --help Show this help"+ echo ""+ echo "What this does:"+ echo " 1. Creates .mcp.json in the project (MCP server config)"+ echo " 2. Adds IX rules to CLAUDE.md (mandatory LLM workflow)"+ echo " 3. Ingests the project's source code into the knowledge graph"+ echo ""+ echo "To disconnect later:"+ echo " ./scripts/disconnect.sh ~/my-project"+ exit 0+ ;;+ *)+ if [ -z "$PROJECT_DIR" ] && [ -d "$1" ]; then+ PROJECT_DIR="$1"+ else+ echo "Unknown option or invalid directory: $1"+ echo "Run './scripts/connect.sh --help' for usage."+ exit 1+ fi+ shift+ ;;+ esac+done++# ── Validate ─────────────────────────────────────────────────────────────────++if [ -z "$PROJECT_DIR" ]; then+ echo "Error: Project directory is required."+ echo ""+ echo "Usage: ./scripts/connect.sh <PROJECT_DIR>"+ echo " e.g. ./scripts/connect.sh ~/my-project"+ exit 1+fi++PROJECT_DIR="$(cd "$PROJECT_DIR" && pwd)"++# Check CLI is built+if [ ! -d "$CLI_DIR/dist" ] || [ ! -d "$CLI_DIR/node_modules" ]; then+ echo "Error: CLI is not built. Run first:"+ echo " ./setup.sh"+ exit 1+fi++# Check backend is running+if ! curl -sf http://localhost:8090/v1/health > /dev/null 2>&1; then+ echo "Error: Backend is not running. Run first:"+ echo " ./setup.sh"+ exit 1+fi++echo ""+echo "╔══════════════════════════════════════════╗"+echo "║ IX-Memory — Connect Project ║"+echo "╚══════════════════════════════════════════╝"+echo ""+echo " Project: $PROJECT_DIR"+echo " IDE: $IDE"+echo ""++# ── Step 1: Install MCP config ──────────────────────────────────────────────++echo "── [1] MCP Config ───────────────────────────────────"++cd "$PROJECT_DIR"++case "$IDE" in+ claude-code)+ $IX_CMD mcp-install --claude-code+ ;;+ claude-desktop)+ $IX_CMD mcp-install+ ;;+ cursor)+ $IX_CMD mcp-install --cursor+ ;;+esac++echo ""++# ── Step 2: Add IX rules to CLAUDE.md ────────────────────────────────────────++echo "── [2] CLAUDE.md ────────────────────────────────────"++cd "$PROJECT_DIR"+$IX_CMD init --force 2>&1 | grep -v "^$" | grep -v "Initializing\|Next:"++echo ""++# ── Step 3: Ingest codebase ─────────────────────────────────────────────────++if [ "$SKIP_INGEST" = true ]; then+ echo "── [3] Ingest (skipped) ───────────────────────────"+else+ echo "── [3] Ingest Codebase ────────────────────────────"+ cd "$PROJECT_DIR"+ "$IX_DIR/scripts/ingest.sh"+fi++# ── Done ─────────────────────────────────────────────────────────────────────++echo ""+echo "╔══════════════════════════════════════════╗"+echo "║ Project connected! ║"+echo "╚══════════════════════════════════════════╝"+echo ""+echo " Project: $PROJECT_DIR"+echo " IDE: $IDE"+echo ""+echo " Next steps:"+echo " 1. Open $PROJECT_DIR in $IDE"+echo " 2. The IX MCP server starts automatically"+echo " 3. Ask Claude questions about your codebase"+echo ""+echo " To disconnect:"+echo " ./scripts/disconnect.sh $PROJECT_DIR"+echo ""diff --git a/scripts/disconnect.sh b/scripts/disconnect.shnew file mode 100755index 00000000..fd78976d--- /dev/null+++ b/scripts/disconnect.sh@@ -0,0 +1,105 @@+#!/usr/bin/env bash+set -euo pipefail++# ─────────────────────────────────────────────────────────────────────────────+# IX-Memory — Disconnect a Project+#+# Removes IX-Memory from a project:+# 1. Removes .mcp.json (so Claude Code no longer sees IX tools)+# 2. Removes IX rules from CLAUDE.md (preserves other content)+#+# Does NOT stop the backend or delete data from the graph.+#+# Usage:+# ./scripts/disconnect.sh ~/my-project+# ─────────────────────────────────────────────────────────────────────────────++IX_MARKER_START="<!-- IX-MEMORY START -->"+IX_MARKER_END="<!-- IX-MEMORY END -->"++# ── Parse arguments ──────────────────────────────────────────────────────────++PROJECT_DIR=""++while [[ $# -gt 0 ]]; do+ case "$1" in+ -h|--help)+ echo "Usage: ./scripts/disconnect.sh <PROJECT_DIR>"+ echo ""+ echo "Removes IX-Memory config from a project."+ echo ""+ echo "What this does:"+ echo " 1. Removes .mcp.json (MCP server config)"+ echo " 2. Removes IX rules from CLAUDE.md (preserves other content)"+ echo ""+ echo "Does NOT stop the backend or delete graph data."+ echo "The project's data stays in the graph — reconnect anytime."+ exit 0+ ;;+ *)+ if [ -z "$PROJECT_DIR" ] && [ -d "$1" ]; then+ PROJECT_DIR="$1"+ else+ echo "Unknown option or invalid directory: $1"+ exit 1+ fi+ shift+ ;;+ esac+done++if [ -z "$PROJECT_DIR" ]; then+ echo "Error: Project directory is required."+ echo ""+ echo "Usage: ./scripts/disconnect.sh <PROJECT_DIR>"+ echo " e.g. ./scripts/disconnect.sh ~/my-project"+ exit 1+fi++PROJECT_DIR="$(cd "$PROJECT_DIR" && pwd)"++echo ""+echo "Disconnecting IX-Memory from: $PROJECT_DIR"+echo ""++# ── Remove .mcp.json ────────────────────────────────────────────────────────++echo "── MCP Config ─────────────────────────────────────"++MCP_JSON="$PROJECT_DIR/.mcp.json"+if [ -f "$MCP_JSON" ]; then+ rm -f "$MCP_JSON"+ echo " [ok] Removed .mcp.json"+else+ echo " [ok] No .mcp.json found"+fi++# ── Remove IX rules from CLAUDE.md ──────────────────────────────────────────++echo ""+echo "── CLAUDE.md ──────────────────────────────────────"++CLAUDE_MD="$PROJECT_DIR/CLAUDE.md"+if [ -f "$CLAUDE_MD" ]; then+ if grep -q "$IX_MARKER_START" "$CLAUDE_MD"; then+ sed -i.bak "/$IX_MARKER_START/,/$IX_MARKER_END/d" "$CLAUDE_MD"+ sed -i.bak -e :a -e '/^\n*$/{$d;N;ba' -e '}' "$CLAUDE_MD"+ rm -f "${CLAUDE_MD}.bak"++ if [ ! -s "$CLAUDE_MD" ] || ! grep -q '[^[:space:]]' "$CLAUDE_MD"; then+ rm -f "$CLAUDE_MD"+ echo " [ok] Removed CLAUDE.md (was only IX rules)"+ else+ echo " [ok] Removed IX rules from CLAUDE.md"+ fi+ else+ echo " [ok] No IX rules found in CLAUDE.md"+ fi+else+ echo " [ok] No CLAUDE.md found"+fi++echo ""+echo "[ok] Project disconnected."+echo " Graph data preserved — run './scripts/connect.sh $PROJECT_DIR' to reconnect."+echo ""diff --git a/scripts/ingest.sh b/scripts/ingest.shnew file mode 100755index 00000000..a0be6f2b--- /dev/null+++ b/scripts/ingest.sh@@ -0,0 +1,105 @@+#!/usr/bin/env bash+set -euo pipefail++# ─────────────────────────────────────────────────────────────────────────────+# IX-Memory — Ingest Codebase+#+# Ingests source files into the IX knowledge graph. Parses code into entities+# (classes, functions, imports, config keys) and builds the versioned graph.+#+# Usage:+# ./scripts/ingest.sh # Auto-detect src/ in current dir+# ./scripts/ingest.sh ./src # Ingest specific directory+# ./scripts/ingest.sh ./src/auth.py # Ingest single file+# ./scripts/ingest.sh ~/my-project/src # Ingest from another project+# ./scripts/ingest.sh --no-recursive ./src # Don't recurse into subdirs+# ─────────────────────────────────────────────────────────────────────────────++IX_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"+CLI_DIR="$IX_DIR/ix-cli"+IX_CMD="npx --prefix $CLI_DIR tsx $CLI_DIR/src/cli/main.ts"++# ── Parse arguments ──────────────────────────────────────────────────────────++INGEST_PATH=""+RECURSIVE="--recursive"++while [[ $# -gt 0 ]]; do+ case "$1" in+ --no-recursive) RECURSIVE=""; shift ;;+ -h|--help)+ echo "Usage: ./scripts/ingest.sh [PATH] [OPTIONS]"+ echo ""+ echo "Arguments:"+ echo " PATH File or directory to ingest (default: auto-detect)"+ echo ""+ echo "Options:"+ echo " --no-recursive Don't recurse into subdirectories"+ echo " -h, --help Show this help"+ echo ""+ echo "Supported file types:"+ echo " .py Python (tree-sitter / regex parser)"+ echo " .ts, .tsx TypeScript (regex parser)"+ echo " .json, .yaml Config files (key extraction)"+ echo " .yml, .toml Config files (key extraction)"+ echo " .md Markdown (heading hierarchy)"+ echo ""+ echo "What this does:"+ echo " 1. Reads source files and computes SHA-256 hashes"+ echo " 2. Skips files that haven't changed since last ingestion"+ echo " 3. Parses entities (classes, functions, imports, config keys)"+ echo " 4. Builds graph patches with deterministic UUIDs"+ echo " 5. Commits patches atomically to ArangoDB"+ exit 0+ ;;+ *)+ INGEST_PATH="$1"+ shift+ ;;+ esac+done++# ── Preflight ────────────────────────────────────────────────────────────────++if [ ! -d "$CLI_DIR/dist" ] || [ ! -d "$CLI_DIR/node_modules" ]; then+ echo "Error: CLI is not built. Run first:"+ echo " ./scripts/build-cli.sh"+ exit 1+fi++if ! curl -sf http://localhost:8090/v1/health > /dev/null 2>&1; then+ echo "Error: Backend is not running. Start it first:"+ echo " ./scripts/backend.sh up"+ exit 1+fi++# ── Auto-detect path ─────────────────────────────────────────────────────────++if [ -z "$INGEST_PATH" ]; then+ if [ -d "./src" ]; then+ INGEST_PATH="./src"+ echo "Auto-detected: ./src"+ elif [ -d "./lib" ]; then+ INGEST_PATH="./lib"+ echo "Auto-detected: ./lib"+ elif [ -d "./app" ]; then+ INGEST_PATH="./app"+ echo "Auto-detected: ./app"+ else+ INGEST_PATH="."+ echo "No src/lib/app directory found — ingesting current directory"+ fi+fi++# Resolve to absolute path+INGEST_PATH="$(cd "$INGEST_PATH" 2>/dev/null && pwd || echo "$INGEST_PATH")"++# ── Ingest ───────────────────────────────────────────────────────────────────++echo "Ingesting: $INGEST_PATH"+echo ""++$IX_CMD ingest "$INGEST_PATH" $RECURSIVE++echo ""+echo "[ok] Ingestion complete"diff --git a/scripts/init-project.sh b/scripts/init-project.shnew file mode 100755index 00000000..96a6d475--- /dev/null+++ b/scripts/init-project.sh@@ -0,0 +1,85 @@+#!/usr/bin/env bash+set -euo pipefail++# ─────────────────────────────────────────────────────────────────────────────+# IX-Memory — Initialize Project+#+# Initializes IX in a target project directory:+# - Verifies backend is running+# - Creates ~/.ix/config.yaml+# - Creates CLAUDE.md with mandatory LLM rules+#+# Usage:+# ./scripts/init-project.sh # Initialize current directory+# ./scripts/init-project.sh ~/my-project # Initialize specific project+# ./scripts/init-project.sh ~/my-project --force # Overwrite existing CLAUDE.md+# ─────────────────────────────────────────────────────────────────────────────++IX_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"+CLI_DIR="$IX_DIR/ix-cli"+IX_CMD="npx --prefix $CLI_DIR tsx $CLI_DIR/src/cli/main.ts"++# ── Parse arguments ──────────────────────────────────────────────────────────++PROJECT_DIR=""+FORCE=""++for arg in "$@"; do+ case "$arg" in+ --force) FORCE="--force" ;;+ -h|--help)+ echo "Usage: ./scripts/init-project.sh [PROJECT_DIR] [--force]"+ echo ""+ echo "Arguments:"+ echo " PROJECT_DIR Target project directory (default: current directory)"+ echo ""+ echo "Options:"+ echo " --force Overwrite existing CLAUDE.md"+ echo " -h, --help Show this help"+ echo ""+ echo "What this does:"+ echo " 1. Checks that the IX backend is running"+ echo " 2. Creates ~/.ix/config.yaml with endpoint settings"+ echo " 3. Creates CLAUDE.md in the project with mandatory LLM rules"+ exit 0+ ;;+ *) PROJECT_DIR="$arg" ;;+ esac+done++# ── Preflight ────────────────────────────────────────────────────────────────++# Verify CLI is built+if [ ! -d "$CLI_DIR/dist" ] || [ ! -d "$CLI_DIR/node_modules" ]; then+ echo "Error: CLI is not built. Run first:"+ echo " ./scripts/build-cli.sh"+ exit 1+fi++# Verify backend is running+if ! curl -sf http://localhost:8090/v1/health > /dev/null 2>&1; then+ echo "Error: Backend is not running. Start it first:"+ echo " ./scripts/backend.sh up"+ exit 1+fi++# ── Initialize ───────────────────────────────────────────────────────────────++if [ -n "$PROJECT_DIR" ]; then+ if [ ! -d "$PROJECT_DIR" ]; then+ echo "Error: Directory does not exist: $PROJECT_DIR"+ exit 1+ fi+ cd "$PROJECT_DIR"+fi++PROJECT_PATH="$(pwd)"+echo "Initializing IX in: $PROJECT_PATH"+echo ""++$IX_CMD init $FORCE++echo ""+echo "[ok] Project initialized"+echo " Config: ~/.ix/config.yaml"+echo " Rules: $PROJECT_PATH/CLAUDE.md"diff --git a/scripts/install-mcp.sh b/scripts/install-mcp.shnew file mode 100755index 00000000..7fd45e93--- /dev/null+++ b/scripts/install-mcp.sh@@ -0,0 +1,110 @@+#!/usr/bin/env bash+set -euo pipefail++# ─────────────────────────────────────────────────────────────────────────────+# IX-Memory — Install MCP Server+#+# Registers the IX MCP server with your IDE so the LLM gets access to+# the 13 IX tools and 2 resources.+#+# Usage:+# ./scripts/install-mcp.sh # Claude Code (default)+# ./scripts/install-mcp.sh --claude-desktop # Claude Desktop+# ./scripts/install-mcp.sh --cursor # Cursor+# ./scripts/install-mcp.sh --claude-code ~/my-project # Claude Code in specific dir+# ─────────────────────────────────────────────────────────────────────────────++IX_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"+CLI_DIR="$IX_DIR/ix-cli"+IX_CMD="npx --prefix $CLI_DIR tsx $CLI_DIR/src/cli/main.ts"++# ── Parse arguments ──────────────────────────────────────────────────────────++IDE="claude-code"+PROJECT_DIR=""++while [[ $# -gt 0 ]]; do+ case "$1" in+ --claude-desktop) IDE="claude-desktop"; shift ;;+ --cursor) IDE="cursor"; shift ;;+ --claude-code) IDE="claude-code"; shift ;;+ -h|--help)+ echo "Usage: ./scripts/install-mcp.sh [IDE] [PROJECT_DIR]"+ echo ""+ echo "IDE Options:"+ echo " --claude-code Install for Claude Code (default)"+ echo " --claude-desktop Install for Claude Desktop"+ echo " --cursor Install for Cursor"+ echo ""+ echo "Arguments:"+ echo " PROJECT_DIR Target project directory (default: current directory)"+ echo " Only relevant for --claude-code and --cursor"+ echo ""+ echo "What this does:"+ echo " Writes MCP server config so the IDE auto-launches the IX MCP server."+ echo " The LLM then gets access to 13 tools (ix_query, ix_decide, etc.)"+ echo " and 2 resources (ix://session/context, ix://project/intent)."+ echo ""+ echo "Config file locations:"+ echo " Claude Code: .claude/settings.json (in project dir)"+ echo " Claude Desktop: ~/Library/Application Support/Claude/claude_desktop_config.json"+ echo " Cursor: .cursor/mcp.json (in project dir)"+ exit 0+ ;;+ *)+ if [ -d "$1" ]; then+ PROJECT_DIR="$1"+ else+ echo "Unknown option or invalid directory: $1"+ exit 1+ fi+ shift+ ;;+ esac+done++# ── Preflight ────────────────────────────────────────────────────────────────++if [ ! -d "$CLI_DIR/dist" ] || [ ! -d "$CLI_DIR/node_modules" ]; then+ echo "Error: CLI is not built. Run first:"+ echo " ./scripts/build-cli.sh"+ exit 1+fi++# ── Install ──────────────────────────────────────────────────────────────────++if [ -n "$PROJECT_DIR" ]; then+ cd "$PROJECT_DIR"+fi++echo "Installing IX MCP server for: $IDE"+echo ""++case "$IDE" in+ claude-code)+ $IX_CMD mcp-install --claude-code+ echo ""+ echo "Config written to: $(pwd)/.claude/settings.json"+ echo "Restart Claude Code to activate."+ ;;+ claude-desktop)+ $IX_CMD mcp-install+ echo ""+ echo "Restart Claude Desktop to activate."+ ;;+ cursor)+ $IX_CMD mcp-install --cursor+ echo ""+ echo "Config written to: $(pwd)/.cursor/mcp.json"+ echo "Restart Cursor to activate."+ ;;+esac++echo ""+echo "[ok] MCP server installed"+echo ""+echo "The LLM will now have access to:"+echo " Tools: ix_query, ix_ingest, ix_decide, ix_search, ix_entity,"+echo " ix_expand, ix_history, ix_truth, ix_diff, ix_conflicts,"+echo " ix_resolve, ix_assert, ix_patches"+echo " Resources: ix://session/context, ix://project/intent"diff --git a/setup.sh b/setup.shnew file mode 100755index 00000000..29904083--- /dev/null+++ b/setup.sh@@ -0,0 +1,92 @@+#!/usr/bin/env bash+set -euo pipefail++# ─────────────────────────────────────────────────────────────────────────────+# IX-Memory — Setup+#+# Starts the IX backend (ArangoDB + Memory Layer) and builds the CLI.+# This runs from the IX-Memory repo — it does NOT touch your projects.+#+# To connect a project, run: ./scripts/connect.sh ~/my-project+#+# Usage:+# ./setup.sh # Start backend + build CLI+# ./setup.sh --skip-backend # Just build CLI (backend already running)+# ─────────────────────────────────────────────────────────────────────────────++IX_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"++SKIP_BACKEND=false++while [[ $# -gt 0 ]]; do+ case "$1" in+ --skip-backend) SKIP_BACKEND=true; shift ;;+ -h|--help)+ echo "Usage: ./setup.sh [OPTIONS]"+ echo ""+ echo "Starts the IX-Memory backend and builds the CLI."+ echo ""+ echo "Options:"+ echo " --skip-backend Skip backend startup (if already running)"+ echo " -h, --help Show this help"+ echo ""+ echo "After setup, connect a project:"+ echo " ./scripts/connect.sh ~/my-project"+ echo ""+ echo "Individual scripts:"+ echo " ./scripts/backend.sh Start/stop Docker containers"+ echo " ./scripts/build-cli.sh Build the TypeScript CLI"+ echo " ./scripts/connect.sh Connect a project (MCP + CLAUDE.md + ingest)"+ echo " ./scripts/disconnect.sh Disconnect a project"+ echo " ./scripts/ingest.sh Ingest files into the graph"+ exit 0+ ;;+ *)+ echo "Unknown option: $1"+ echo "Run './setup.sh --help' for usage."+ exit 1+ ;;+ esac+done++echo ""+echo "╔══════════════════════════════════════════╗"+echo "║ IX-Memory — Setup ║"+echo "╚══════════════════════════════════════════╝"+echo ""++# ── Step 1: Backend ──────────────────────────────────────────────────────────++echo "── [1] Backend ────────────────────────────────────"+if [ "$SKIP_BACKEND" = true ]; then+ echo " (skipped via --skip-backend)"+ if ! "$IX_DIR/scripts/backend.sh" check 2>/dev/null; then+ echo " Warning: Backend is not responding."+ fi+else+ "$IX_DIR/scripts/backend.sh" up+fi++echo ""++# ── Step 2: Build CLI ────────────────────────────────────────────────────────++echo "── [2] Build CLI ──────────────────────────────────"+"$IX_DIR/scripts/build-cli.sh"++# ── Done ─────────────────────────────────────────────────────────────────────++echo ""+echo "╔══════════════════════════════════════════╗"+echo "║ IX backend is ready! ║"+echo "╚══════════════════════════════════════════╝"+echo ""+echo " Backend: http://localhost:8090"+echo " ArangoDB: http://localhost:8529"+echo ""+echo " Next: connect a project to IX:"+echo " ./scripts/connect.sh ~/my-project"+echo ""+echo " Or with a specific IDE:"+echo " ./scripts/connect.sh ~/my-project --cursor"+echo ""diff --git a/shutdown.sh b/shutdown.shnew file mode 100755index 00000000..910ec0ea--- /dev/null+++ b/shutdown.sh@@ -0,0 +1,128 @@+#!/usr/bin/env bash+set -euo pipefail++# ─────────────────────────────────────────────────────────────────────────────+# IX-Memory — Shutdown+#+# Stops the IX backend (Docker containers + MCP server processes).+# Optionally disconnects projects too.+#+# Usage:+# ./shutdown.sh # Stop backend only+# ./shutdown.sh --clean # Stop + remove data volumes+# ./shutdown.sh --disconnect ~/my-project # Stop + disconnect a project+# ./shutdown.sh --disconnect ~/app1 ~/app2 # Stop + disconnect multiple+# ./shutdown.sh --clean --disconnect ~/my-project # Full teardown+# ─────────────────────────────────────────────────────────────────────────────++IX_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"+cd "$IX_DIR"++CLEAN=false+DISCONNECT_PROJECTS=()++while [[ $# -gt 0 ]]; do+ case "$1" in+ --clean) CLEAN=true; shift ;;+ --disconnect)+ shift+ # Collect all following paths until we hit another flag or end+ while [[ $# -gt 0 ]] && [[ "$1" != --* ]]; do+ DISCONNECT_PROJECTS+=("$1")+ shift+ done+ if [ ${#DISCONNECT_PROJECTS[@]} -eq 0 ]; then+ echo "Error: --disconnect requires at least one project path."+ echo " e.g. ./shutdown.sh --disconnect ~/my-project"+ exit 1+ fi+ ;;+ -h|--help)+ echo "Usage: ./shutdown.sh [OPTIONS]"+ echo ""+ echo "Stops the IX-Memory backend."+ echo ""+ echo "Options:"+ echo " --clean Stop + remove data volumes (fresh start)"+ echo " --disconnect <path> [paths] Disconnect projects before stopping"+ echo " -h, --help Show this help"+ echo ""+ echo "Examples:"+ echo " ./shutdown.sh Stop backend only"+ echo " ./shutdown.sh --disconnect ~/my-app Stop + disconnect project"+ echo " ./shutdown.sh --disconnect ~/app1 ~/app2 Stop + disconnect multiple"+ echo " ./shutdown.sh --clean --disconnect ~/my-app Full teardown"+ exit 0+ ;;+ *) echo "Unknown option: $1"; exit 1 ;;+ esac+done++echo ""+echo "╔══════════════════════════════════════════╗"+echo "║ IX-Memory — Shutdown ║"+echo "╚══════════════════════════════════════════╝"+echo ""++# ── Disconnect projects ──────────────────────────────────────────────────────++if [ ${#DISCONNECT_PROJECTS[@]} -gt 0 ]; then+ echo "── Disconnect Projects ────────────────────────────"+ for project in "${DISCONNECT_PROJECTS[@]}"; do+ if [ -d "$project" ]; then+ "$IX_DIR/scripts/disconnect.sh" "$project" 2>&1 | sed 's/^/ /'+ else+ echo " [!!] Directory not found: $project"+ fi+ done+ echo ""+fi++# ── Stop MCP server processes ────────────────────────────────────────────────++echo "── MCP Server ─────────────────────────────────────"++MCP_PIDS=$(pgrep -f "ix-cli/src/mcp/server.ts" 2>/dev/null || true)+if [ -n "$MCP_PIDS" ]; then+ echo " Stopping MCP server processes: $MCP_PIDS"+ echo "$MCP_PIDS" | xargs kill 2>/dev/null || true+ sleep 1+ REMAINING=$(pgrep -f "ix-cli/src/mcp/server.ts" 2>/dev/null || true)+ if [ -n "$REMAINING" ]; then+ echo " Force killing remaining: $REMAINING"+ echo "$REMAINING" | xargs kill -9 2>/dev/null || true+ fi+ echo " [ok] MCP server stopped"+else+ echo " [ok] MCP server not running"+fi++# ── Stop Docker containers ───────────────────────────────────────────────────++echo ""+echo "── Docker Containers ──────────────────────────────"++if ! command -v docker &> /dev/null; then+ echo " [ok] Docker not installed, nothing to stop"+elif ! docker info &> /dev/null 2>&1; then+ echo " [ok] Docker not running, nothing to stop"+else+ if [ "$CLEAN" = true ]; then+ docker compose down -v 2>&1 | sed 's/^/ /'+ echo " [ok] Containers stopped and data volumes removed"+ else+ docker compose down 2>&1 | sed 's/^/ /'+ echo " [ok] Containers stopped (data preserved)"+ fi+fi++# ── Summary ──────────────────────────────────────────────────────────────────++echo ""+echo "IX backend stopped."+if [ "$CLEAN" = true ]; then+ echo " Data volumes removed. Next './setup.sh' will start fresh."+else+ echo " Data preserved. Run './setup.sh' to start again."+fi+echo ""