Skip to content

armgit / Ix

Public Imported from GitHub
0

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

feat: ix reset — wipe graph for clean re-ingest

kagebinary2330d0701c35
diff --git a/ix-cli/src/cli/commands/reset.ts b/ix-cli/src/cli/commands/reset.ts
new file mode 100644
index 00000000..dcf57b02
--- /dev/null
+++ b/ix-cli/src/cli/commands/reset.ts
@@ -0,0 +1,35 @@
+import type { Command } from "commander";
+import chalk from "chalk";
+import { IxClient } from "../../client/api.js";
+import { getEndpoint } from "../config.js";
+
+export function registerResetCommand(program: Command): void {
+ program
+ .command("reset")
+ .description("Wipe all graph data (nodes + edges) for a clean re-ingest")
+ .option("-y, --yes", "Skip confirmation prompt")
+ .action(async (opts: { yes?: boolean }) => {
+ if (!opts.yes) {
+ process.stdout.write(
+ chalk.yellow("This will delete all nodes and edges. Are you sure? (y/N) ")
+ );
+ const answer = await new Promise<string>(resolve => {
+ process.stdin.setEncoding("utf8");
+ process.stdin.once("data", (chunk: string) => resolve(chunk.trim()));
+ });
+ if (answer.toLowerCase() !== "y") {
+ console.log(chalk.dim("Aborted."));
+ return;
+ }
+ }
+
+ const client = new IxClient(getEndpoint());
+ try {
+ await client.reset();
+ console.log(chalk.green("✓") + " Graph wiped. Run " + chalk.bold("ix ingest . --recursive") + " to re-ingest.");
+ } catch (err: any) {
+ console.error(chalk.red("Error:"), err.message);
+ process.exitCode = 1;
+ }
+ });
+}
diff --git a/ix-cli/src/cli/register/oss.ts b/ix-cli/src/cli/register/oss.ts
index fd6c5894..b67b53d9 100644
--- a/ix-cli/src/cli/register/oss.ts
+++ b/ix-cli/src/cli/register/oss.ts
@@ -26,6 +26,7 @@ import { registerWatchCommand } from "../commands/watch.js";
import { registerDockerCommand } from "../commands/docker.js";
import { registerWorkflowsHelpCommand } from "../commands/workflows.js";
import { registerMapCommand } from "../commands/map.js";
+import { registerResetCommand } from "../commands/reset.js";
const PRO_COMMANDS: { name: string; desc: string }[] = [
{ name: "briefing", desc: "Session-resume briefing" },
@@ -78,6 +79,7 @@ export function registerOssCommands(program: Command): void {
registerDockerCommand(program);
registerWorkflowsHelpCommand(program);
registerMapCommand(program);
+ registerResetCommand(program);
// Hide advanced commands from default help
const advancedSet = new Set(ADVANCED_COMMANDS);
diff --git a/ix-cli/src/client/api.ts b/ix-cli/src/client/api.ts
index 0e2e9138..0af60ea7 100644
--- a/ix-cli/src/client/api.ts
+++ b/ix-cli/src/client/api.ts
@@ -178,6 +178,10 @@ export class IxClient {
return this.post("/v1/map", {});
}
+ async reset(): Promise<{ ok: boolean; message: string }> {
+ return this.post("/v1/reset", {});
+ }
+
async stats(): Promise<any> {
return this.get("/v1/stats");
}
diff --git a/memory-layer/src/main/scala/ix/memory/api/ResetRoutes.scala b/memory-layer/src/main/scala/ix/memory/api/ResetRoutes.scala
new file mode 100644
index 00000000..9b1847e1
--- /dev/null
+++ b/memory-layer/src/main/scala/ix/memory/api/ResetRoutes.scala
@@ -0,0 +1,23 @@
+package ix.memory.api
+
+import cats.effect.IO
+import io.circe.Json
+import io.circe.syntax._
+import org.http4s.HttpRoutes
+import org.http4s.circe.CirceEntityCodec._
+import org.http4s.dsl.io._
+
+import ix.memory.db.ArangoClient
+
+class ResetRoutes(client: ArangoClient) {
+
+ val routes: HttpRoutes[IO] = HttpRoutes.of[IO] {
+
+ /** POST /v1/reset — Truncate all graph data (nodes + edges). Dev use only. */
+ case POST -> Root / "v1" / "reset" =>
+ (for {
+ _ <- client.truncateGraph()
+ r <- Ok(Json.obj("ok" -> true.asJson, "message" -> "Graph reset. All nodes and edges deleted.".asJson))
+ } yield r).handleErrorWith(ErrorHandler.handle(_))
+ }
+}
diff --git a/memory-layer/src/main/scala/ix/memory/api/Routes.scala b/memory-layer/src/main/scala/ix/memory/api/Routes.scala
index f2dd63db..f97e5f3c 100644
--- a/memory-layer/src/main/scala/ix/memory/api/Routes.scala
+++ b/memory-layer/src/main/scala/ix/memory/api/Routes.scala
@@ -44,11 +44,12 @@ object Routes {
val patchCommitRoutes = new PatchCommitRoutes(writeApi).routes
val listRoutes = new ListRoutes(queryApi).routes
val mapRoutes = new MapRoutes(mapService).routes
+ val resetRoutes = new ResetRoutes(client).routes
health <+> contextRoutes <+> entityRoutes <+>
diffRoutes <+> conflictRoutes <+> decideRoutes <+> searchRoutes <+>
truthRoutes <+> patchRoutes <+> decisionListRoutes <+> expandRoutes <+>
statsRoutes <+> patchCommitRoutes <+> listRoutes <+> goalRoutes <+>
- mapRoutes
+ mapRoutes <+> resetRoutes
}
}
diff --git a/memory-layer/src/main/scala/ix/memory/db/ArangoClient.scala b/memory-layer/src/main/scala/ix/memory/db/ArangoClient.scala
index 833bc01a..eacfee62 100644
--- a/memory-layer/src/main/scala/ix/memory/db/ArangoClient.scala
+++ b/memory-layer/src/main/scala/ix/memory/db/ArangoClient.scala
@@ -106,6 +106,14 @@ class ArangoClient private (db: ArangoDatabase) {
}
def ensureSchema(): IO[Unit] = ArangoSchema.ensure(db)
+
+ /** Truncate all graph collections (nodes + edges). Destructive — dev use only. */
+ def truncateGraph(): IO[Unit] =
+ IO.blocking {
+ db.collection("nodes").truncate()
+ db.collection("edges").truncate()
+ ()
+ }
}
object ArangoClient {