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: wire workspace root resolution into text, read, ingest, locate commands
riley0227d4eaecc1f3b2
diff --git a/ix-cli/src/cli/commands/ingest.ts b/ix-cli/src/cli/commands/ingest.tsindex 46dbe070..c1980534 100644--- a/ix-cli/src/cli/commands/ingest.ts+++ b/ix-cli/src/cli/commands/ingest.ts@@ -1,7 +1,8 @@+import * as nodePath from "node:path";import type { Command } from "commander";import chalk from "chalk";import { IxClient } from "../../client/api.js";-import { getEndpoint } from "../config.js";+import { getEndpoint, resolveWorkspaceRoot } from "../config.js";export function registerIngestCommand(program: Command): void {program@@ -9,7 +10,10 @@ export function registerIngestCommand(program: Command): void {.description("Ingest source files into the knowledge graph").option("--recursive", "Recursively ingest directory").option("--format <fmt>", "Output format (text|json)", "text")- .action(async (path: string, opts: { recursive?: boolean; format: string }) => {+ .option("--root <dir>", "Workspace root directory")+ .action(async (path: string, opts: { recursive?: boolean; format: string; root?: string }) => {+ // Resolve relative paths against workspace root+ const resolvedPath = nodePath.isAbsolute(path) ? path : nodePath.resolve(resolveWorkspaceRoot(opts.root), path);const client = new IxClient(getEndpoint());const start = performance.now();@@ -22,7 +26,7 @@ export function registerIngestCommand(program: Command): void {}, 200) : null;try {- const result = await client.ingest(path, opts.recursive);+ const result = await client.ingest(resolvedPath, opts.recursive);if (interval) {clearInterval(interval);process.stderr.write("\r" + " ".repeat(40) + "\r");diff --git a/ix-cli/src/cli/commands/locate.ts b/ix-cli/src/cli/commands/locate.tsindex 7b6bcfa1..16188d14 100644--- a/ix-cli/src/cli/commands/locate.ts+++ b/ix-cli/src/cli/commands/locate.ts@@ -2,7 +2,7 @@ import { execFile } from "node:child_process";import { promisify } from "node:util";import type { Command } from "commander";import { IxClient } from "../../client/api.js";-import { getEndpoint } from "../config.js";+import { getEndpoint, resolveWorkspaceRoot } from "../config.js";import { formatLocateResults, type LocateResult } from "../format.js";const execFileAsync = promisify(execFile);@@ -13,7 +13,8 @@ export function registerLocateCommand(program: Command): void {.description("Find a symbol in code and resolve to graph entities").option("--limit <n>", "Max text hits to check", "10").option("--format <fmt>", "Output format (text|json)", "text")- .action(async (symbol: string, opts: { limit: string; format: string }) => {+ .option("--root <dir>", "Workspace root directory")+ .action(async (symbol: string, opts: { limit: string; format: string; root?: string }) => {const client = new IxClient(getEndpoint());const limit = parseInt(opts.limit, 10);@@ -26,7 +27,7 @@ export function registerLocateCommand(program: Command): void {const { stdout } = await execFileAsync("rg", ["--json", "--max-count", String(limit),"--no-heading", "--word-regexp",- symbol, ".",+ symbol, resolveWorkspaceRoot(opts.root),], { maxBuffer: 10 * 1024 * 1024 });for (const line of stdout.split("\n")) {diff --git a/ix-cli/src/cli/commands/read.ts b/ix-cli/src/cli/commands/read.tsindex 9b85408f..7a566906 100644--- a/ix-cli/src/cli/commands/read.ts+++ b/ix-cli/src/cli/commands/read.ts@@ -1,8 +1,9 @@import * as fs from "node:fs";+import * as path from "node:path";import type { Command } from "commander";import chalk from "chalk";import { IxClient } from "../../client/api.js";-import { getEndpoint } from "../config.js";+import { getEndpoint, resolveWorkspaceRoot } from "../config.js";import { resolveEntity } from "../resolve.js";export function registerReadCommand(program: Command): void {@@ -11,10 +12,13 @@ export function registerReadCommand(program: Command): void {.description("Read source code — by file path, path:lines, or symbol name").option("--format <fmt>", "Output format (text|json)", "text").option("--kind <kind>", "Filter symbol by kind")- .action(async (target: string, opts: { format: string; kind?: string }) => {+ .option("--root <dir>", "Workspace root directory")+ .action(async (target: string, opts: { format: string; kind?: string; root?: string }) => {// Check if target has a line range (path:start-end)const lineRangeMatch = target.match(/^(.+?):(\d+)-(\d+)$/);- const filePath = lineRangeMatch ? lineRangeMatch[1] : target;+ const rawPath = lineRangeMatch ? lineRangeMatch[1] : target;+ // Resolve relative paths against workspace root+ const filePath = path.isAbsolute(rawPath) ? rawPath : path.resolve(resolveWorkspaceRoot(opts.root), rawPath);// Try as a file path firstif (fs.existsSync(filePath)) {diff --git a/ix-cli/src/cli/commands/text.ts b/ix-cli/src/cli/commands/text.tsindex 991921c0..c8ed9e36 100644--- a/ix-cli/src/cli/commands/text.ts+++ b/ix-cli/src/cli/commands/text.ts@@ -2,6 +2,7 @@ import { execFile } from "node:child_process";import { promisify } from "node:util";import type { Command } from "commander";import { formatTextResults, type TextResult } from "../format.js";+import { resolveWorkspaceRoot } from "../config.js";const execFileAsync = promisify(execFile);@@ -13,8 +14,10 @@ export function registerTextCommand(program: Command): void {.option("--path <dir>", "Restrict search to a directory", ".").option("--language <lang>", "Filter by language (python, typescript, scala, etc.)").option("--format <fmt>", "Output format (text|json)", "text")- .action(async (term: string, opts: { limit: string; path: string; format: string; language?: string }) => {+ .option("--root <dir>", "Workspace root directory")+ .action(async (term: string, opts: { limit: string; path: string; format: string; language?: string; root?: string }) => {const limit = parseInt(opts.limit, 10);+ const searchPath = opts.path !== "." ? opts.path : resolveWorkspaceRoot(opts.root);try {const rgArgs = ["--json",@@ -27,7 +30,7 @@ export function registerTextCommand(program: Command): void {}}- rgArgs.push(term, opts.path);+ rgArgs.push(term, searchPath);const { stdout } = await execFileAsync("rg", rgArgs, { maxBuffer: 10 * 1024 * 1024 });