diff --git a/packages/cli-uwf/src/cli.ts b/packages/cli-uwf/src/cli.ts index 1f128ef..bbcf5ba 100755 --- a/packages/cli-uwf/src/cli.ts +++ b/packages/cli-uwf/src/cli.ts @@ -15,6 +15,7 @@ import { cmdCasGet, cmdCasHas, cmdCasPut, + cmdCasReindex, cmdCasRefs, cmdCasSchemaGet, cmdCasSchemaList, @@ -239,6 +240,16 @@ cas }); }); +cas + .command("reindex") + .description("Rebuild type index from all CAS nodes") + .action(() => { + const storageRoot = resolveStorageRoot(); + runAction(async () => { + writeOutput(await cmdCasReindex(storageRoot)); + }); + }); + const casSchema = cas.command("schema").description("CAS schema operations"); casSchema diff --git a/packages/cli-uwf/src/commands/cas.ts b/packages/cli-uwf/src/commands/cas.ts index 1a7bec6..15469dd 100644 --- a/packages/cli-uwf/src/commands/cas.ts +++ b/packages/cli-uwf/src/commands/cas.ts @@ -115,6 +115,17 @@ export async function cmdCasSchemaList( return entries; } +export async function cmdCasReindex( + storageRoot: string, +): Promise<{ status: string }> { + const indexDir = join(storageRoot, "cas", "_index"); + const { rmSync } = await import("node:fs"); + rmSync(indexDir, { recursive: true, force: true }); + // Re-open store to trigger migration rebuild + openStore(storageRoot); + return { status: "reindexed" }; +} + export async function cmdCasSchemaGet( storageRoot: string, hash: string,