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: ix CLI commands — query, ingest, decide, search, truth, patches, status, entity, history, conflicts, diff
riley02276c0fc100c87b
diff --git a/ix-cli/src/cli/commands/conflicts.ts b/ix-cli/src/cli/commands/conflicts.tsnew file mode 100644index 00000000..75e217ef--- /dev/null+++ b/ix-cli/src/cli/commands/conflicts.ts@@ -0,0 +1,23 @@+import type { Command } from "commander";+import { IxClient } from "../../client/api.js";+import { getEndpoint } from "../config.js";++export function registerConflictsCommand(program: Command): void {+ program+ .command("conflicts")+ .description("List detected conflicts")+ .option("--format <fmt>", "Output format (text|json)", "text")+ .action(async (opts: { format: string }) => {+ const client = new IxClient(getEndpoint());+ const conflicts = await client.conflicts();+ if (opts.format === "json") {+ console.log(JSON.stringify(conflicts, null, 2));+ } else {+ if ((conflicts as unknown[]).length === 0) {+ console.log("No conflicts detected.");+ } else {+ console.log(JSON.stringify(conflicts, null, 2));+ }+ }+ });+}diff --git a/ix-cli/src/cli/commands/decide.ts b/ix-cli/src/cli/commands/decide.tsnew file mode 100644index 00000000..8de6c32f--- /dev/null+++ b/ix-cli/src/cli/commands/decide.ts@@ -0,0 +1,21 @@+import type { Command } from "commander";+import { IxClient } from "../../client/api.js";+import { getEndpoint } from "../config.js";++export function registerDecideCommand(program: Command): void {+ program+ .command("decide <title>")+ .description("Record a design decision")+ .requiredOption("--rationale <text>", "Rationale for the decision")+ .option("--intent-id <id>", "Link to an intent")+ .option("--format <fmt>", "Output format (text|json)", "text")+ .action(async (title: string, opts: { rationale: string; intentId?: string; format: string }) => {+ const client = new IxClient(getEndpoint());+ const result = await client.decide(title, opts.rationale, { intentId: opts.intentId });+ if (opts.format === "json") {+ console.log(JSON.stringify(result, null, 2));+ } else {+ console.log(`Decision recorded: ${result.nodeId} (rev ${result.rev})`);+ }+ });+}diff --git a/ix-cli/src/cli/commands/diff.ts b/ix-cli/src/cli/commands/diff.tsnew file mode 100644index 00000000..6076d831--- /dev/null+++ b/ix-cli/src/cli/commands/diff.ts@@ -0,0 +1,20 @@+import type { Command } from "commander";+import { IxClient } from "../../client/api.js";+import { getEndpoint } from "../config.js";++export function registerDiffCommand(program: Command): void {+ program+ .command("diff <fromRev> <toRev>")+ .description("Show diff between two revisions")+ .option("--entity <id>", "Filter by entity ID")+ .option("--format <fmt>", "Output format (text|json)", "text")+ .action(async (fromRev: string, toRev: string, opts: { entity?: string; format: string }) => {+ const client = new IxClient(getEndpoint());+ const result = await client.diff(parseInt(fromRev, 10), parseInt(toRev, 10), opts.entity);+ if (opts.format === "json") {+ console.log(JSON.stringify(result, null, 2));+ } else {+ console.log(JSON.stringify(result, null, 2));+ }+ });+}diff --git a/ix-cli/src/cli/commands/entity.ts b/ix-cli/src/cli/commands/entity.tsnew file mode 100644index 00000000..6fd48e81--- /dev/null+++ b/ix-cli/src/cli/commands/entity.ts@@ -0,0 +1,21 @@+import type { Command } from "commander";+import { IxClient } from "../../client/api.js";+import { getEndpoint } from "../config.js";++export function registerEntityCommand(program: Command): void {+ program+ .command("entity <id>")+ .description("Get entity details with claims and edges")+ .option("--format <fmt>", "Output format (text|json)", "text")+ .action(async (id: string, opts: { format: string }) => {+ const client = new IxClient(getEndpoint());+ const result = await client.entity(id);+ if (opts.format === "json") {+ console.log(JSON.stringify(result, null, 2));+ } else {+ console.log(`Entity: ${result.node.id} (${result.node.kind})`);+ console.log(`Claims: ${(result.claims as unknown[]).length}`);+ console.log(`Edges: ${(result.edges as unknown[]).length}`);+ }+ });+}diff --git a/ix-cli/src/cli/commands/history.ts b/ix-cli/src/cli/commands/history.tsnew file mode 100644index 00000000..c336b794--- /dev/null+++ b/ix-cli/src/cli/commands/history.ts@@ -0,0 +1,19 @@+import type { Command } from "commander";+import { IxClient } from "../../client/api.js";+import { getEndpoint } from "../config.js";++export function registerHistoryCommand(program: Command): void {+ program+ .command("history <entityId>")+ .description("Show provenance chain for an entity")+ .option("--format <fmt>", "Output format (text|json)", "text")+ .action(async (entityId: string, opts: { format: string }) => {+ const client = new IxClient(getEndpoint());+ const result = await client.provenance(entityId);+ if (opts.format === "json") {+ console.log(JSON.stringify(result, null, 2));+ } else {+ console.log(JSON.stringify(result, null, 2));+ }+ });+}diff --git a/ix-cli/src/cli/commands/ingest.ts b/ix-cli/src/cli/commands/ingest.tsnew file mode 100644index 00000000..97833a06--- /dev/null+++ b/ix-cli/src/cli/commands/ingest.ts@@ -0,0 +1,20 @@+import type { Command } from "commander";+import { IxClient } from "../../client/api.js";+import { getEndpoint } from "../config.js";++export function registerIngestCommand(program: Command): void {+ program+ .command("ingest <path>")+ .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 }) => {+ const client = new IxClient(getEndpoint());+ const result = await client.ingest(path, opts.recursive);+ if (opts.format === "json") {+ console.log(JSON.stringify(result, null, 2));+ } else {+ console.log(`Ingested: rev ${result.newRev} (${result.status})`);+ }+ });+}diff --git a/ix-cli/src/cli/commands/patches.ts b/ix-cli/src/cli/commands/patches.tsnew file mode 100644index 00000000..39262e61--- /dev/null+++ b/ix-cli/src/cli/commands/patches.ts@@ -0,0 +1,16 @@+import type { Command } from "commander";+import { IxClient } from "../../client/api.js";+import { getEndpoint } from "../config.js";+import { formatPatches } from "../format.js";++export function registerPatchesCommand(program: Command): void {+ program+ .command("patches")+ .description("List recent patches")+ .option("--format <fmt>", "Output format (text|json)", "text")+ .action(async (opts: { format: string }) => {+ const client = new IxClient(getEndpoint());+ const patches = await client.listPatches();+ formatPatches(patches, opts.format);+ });+}diff --git a/ix-cli/src/cli/commands/query.ts b/ix-cli/src/cli/commands/query.tsnew file mode 100644index 00000000..bbc74e00--- /dev/null+++ b/ix-cli/src/cli/commands/query.ts@@ -0,0 +1,21 @@+import type { Command } from "commander";+import { IxClient } from "../../client/api.js";+import { getEndpoint } from "../config.js";+import { formatContext } from "../format.js";++export function registerQueryCommand(program: Command): void {+ program+ .command("query <question>")+ .description("Query the knowledge graph for structured context")+ .option("--as-of <rev>", "Time-travel to a specific revision")+ .option("--depth <depth>", "Query depth (shallow|standard|deep)", "standard")+ .option("--format <fmt>", "Output format (text|json)", "text")+ .action(async (question: string, opts: { asOf?: string; depth?: string; format: string }) => {+ const client = new IxClient(getEndpoint());+ const result = await client.query(question, {+ asOfRev: opts.asOf ? parseInt(opts.asOf, 10) : undefined,+ depth: opts.depth,+ });+ formatContext(result, opts.format);+ });+}diff --git a/ix-cli/src/cli/commands/search.ts b/ix-cli/src/cli/commands/search.tsnew file mode 100644index 00000000..bcc5b9c0--- /dev/null+++ b/ix-cli/src/cli/commands/search.ts@@ -0,0 +1,17 @@+import type { Command } from "commander";+import { IxClient } from "../../client/api.js";+import { getEndpoint } from "../config.js";+import { formatNodes } from "../format.js";++export function registerSearchCommand(program: Command): void {+ program+ .command("search <term>")+ .description("Search the knowledge graph by term")+ .option("--limit <n>", "Max results", "20")+ .option("--format <fmt>", "Output format (text|json)", "text")+ .action(async (term: string, opts: { limit: string; format: string }) => {+ const client = new IxClient(getEndpoint());+ const nodes = await client.search(term, parseInt(opts.limit, 10));+ formatNodes(nodes, opts.format);+ });+}diff --git a/ix-cli/src/cli/commands/status.ts b/ix-cli/src/cli/commands/status.tsnew file mode 100644index 00000000..deaeffeb--- /dev/null+++ b/ix-cli/src/cli/commands/status.ts@@ -0,0 +1,25 @@+import type { Command } from "commander";+import { IxClient } from "../../client/api.js";+import { getEndpoint } from "../config.js";++export function registerStatusCommand(program: Command): void {+ program+ .command("status")+ .description("Show Ix backend health and status")+ .option("--format <fmt>", "Output format (text|json)", "text")+ .action(async (opts: { format: string }) => {+ const client = new IxClient(getEndpoint());+ try {+ const health = await client.health();+ if (opts.format === "json") {+ console.log(JSON.stringify(health, null, 2));+ } else {+ console.log(`Ix Memory: ${health.status}`);+ console.log(`Endpoint: ${getEndpoint()}`);+ }+ } catch (err) {+ console.error(`Ix backend not reachable at ${getEndpoint()}`);+ process.exit(1);+ }+ });+}diff --git a/ix-cli/src/cli/commands/truth.ts b/ix-cli/src/cli/commands/truth.tsnew file mode 100644index 00000000..914d3fa7--- /dev/null+++ b/ix-cli/src/cli/commands/truth.ts@@ -0,0 +1,35 @@+import type { Command } from "commander";+import { IxClient } from "../../client/api.js";+import { getEndpoint } from "../config.js";+import { formatNodes } from "../format.js";++export function registerTruthCommand(program: Command): void {+ const truth = program+ .command("truth")+ .description("Manage project intents (truth)");++ truth+ .command("list")+ .description("List all intents")+ .option("--format <fmt>", "Output format (text|json)", "text")+ .action(async (opts: { format: string }) => {+ const client = new IxClient(getEndpoint());+ const intents = await client.listTruth();+ formatNodes(intents, opts.format);+ });++ truth+ .command("add <statement>")+ .description("Add a new intent")+ .option("--parent <id>", "Parent intent ID")+ .option("--format <fmt>", "Output format (text|json)", "text")+ .action(async (statement: string, opts: { parent?: string; format: string }) => {+ const client = new IxClient(getEndpoint());+ const result = await client.createTruth(statement, opts.parent);+ if (opts.format === "json") {+ console.log(JSON.stringify(result, null, 2));+ } else {+ console.log(`Intent created: ${result.nodeId} (rev ${result.rev})`);+ }+ });+}diff --git a/ix-cli/src/cli/config.ts b/ix-cli/src/cli/config.tsnew file mode 100644index 00000000..39a544a5--- /dev/null+++ b/ix-cli/src/cli/config.ts@@ -0,0 +1,30 @@+import { readFileSync, existsSync } from "node:fs";+import { join } from "node:path";+import { homedir } from "node:os";+import { parse } from "yaml";++export interface IxConfig {+ endpoint: string;+ format: string;+}++const defaultConfig: IxConfig = {+ endpoint: "http://localhost:8090",+ format: "text",+};++export function loadConfig(): IxConfig {+ const configPath = join(homedir(), ".ix", "config.yaml");+ if (!existsSync(configPath)) return defaultConfig;+ try {+ const raw = readFileSync(configPath, "utf-8");+ const parsed = parse(raw) as Partial<IxConfig>;+ return { ...defaultConfig, ...parsed };+ } catch {+ return defaultConfig;+ }+}++export function getEndpoint(): string {+ return process.env.IX_ENDPOINT || loadConfig().endpoint;+}diff --git a/ix-cli/src/cli/format.ts b/ix-cli/src/cli/format.tsnew file mode 100644index 00000000..6dcf01ac--- /dev/null+++ b/ix-cli/src/cli/format.ts@@ -0,0 +1,71 @@+export function formatContext(result: any, format: string): void {+ if (format === "json") {+ console.log(JSON.stringify(result, null, 2));+ return;+ }++ // Text format+ const { claims, conflicts, decisions, intents, metadata } = result;++ console.log(`\n--- Ix Context: "${metadata.query}" ---`);+ console.log(`Seeds: ${metadata.seedEntities.length} | Hops: ${metadata.hopsExpanded} | Rev: ${metadata.asOfRev}`);++ if (claims && claims.length > 0) {+ console.log(`\nClaims (${claims.length}):`);+ for (const sc of claims.slice(0, 10)) {+ const conf = (sc.finalScore * 100).toFixed(0);+ console.log(` [${conf}%] ${sc.claim.statement}`);+ }+ if (claims.length > 10) console.log(` ... and ${claims.length - 10} more`);+ }++ if (conflicts && conflicts.length > 0) {+ console.log(`\nConflicts (${conflicts.length}):`);+ for (const c of conflicts) {+ console.log(` ! ${c.reason}: ${c.recommendation}`);+ }+ }++ if (decisions && decisions.length > 0) {+ console.log(`\nDecisions (${decisions.length}):`);+ for (const d of decisions) {+ console.log(` * ${d.title}: ${d.rationale}`);+ }+ }++ if (intents && intents.length > 0) {+ console.log(`\nIntents (${intents.length}):`);+ for (const i of intents) {+ console.log(` > ${i.statement} [${i.status}]`);+ }+ }+ console.log();+}++export function formatNodes(nodes: any[], format: string): void {+ if (format === "json") {+ console.log(JSON.stringify(nodes, null, 2));+ return;+ }+ if (nodes.length === 0) {+ console.log("No results found.");+ return;+ }+ for (const n of nodes) {+ console.log(` ${n.kind} ${n.id} attrs: ${JSON.stringify(n.attrs)}`);+ }+}++export function formatPatches(patches: any[], format: string): void {+ if (format === "json") {+ console.log(JSON.stringify(patches, null, 2));+ return;+ }+ if (patches.length === 0) {+ console.log("No patches found.");+ return;+ }+ for (const p of patches) {+ console.log(` rev ${p.rev} ${p.patch_id} ${p.intent || "(no intent)"}`);+ }+}diff --git a/ix-cli/src/cli/main.ts b/ix-cli/src/cli/main.tsnew file mode 100644index 00000000..e3a84509--- /dev/null+++ b/ix-cli/src/cli/main.ts@@ -0,0 +1,33 @@+#!/usr/bin/env node+import { Command } from "commander";+import { registerQueryCommand } from "./commands/query.js";+import { registerIngestCommand } from "./commands/ingest.js";+import { registerDecideCommand } from "./commands/decide.js";+import { registerSearchCommand } from "./commands/search.js";+import { registerTruthCommand } from "./commands/truth.js";+import { registerPatchesCommand } from "./commands/patches.js";+import { registerStatusCommand } from "./commands/status.js";+import { registerEntityCommand } from "./commands/entity.js";+import { registerHistoryCommand } from "./commands/history.js";+import { registerConflictsCommand } from "./commands/conflicts.js";+import { registerDiffCommand } from "./commands/diff.js";++const program = new Command();+program+ .name("ix")+ .description("Ix Memory — Persistent Memory for LLM Systems")+ .version("0.1.0");++registerQueryCommand(program);+registerIngestCommand(program);+registerDecideCommand(program);+registerSearchCommand(program);+registerTruthCommand(program);+registerPatchesCommand(program);+registerStatusCommand(program);+registerEntityCommand(program);+registerHistoryCommand(program);+registerConflictsCommand(program);+registerDiffCommand(program);++program.parse();