diff --git a/extensions/memory-core/src/cli-status.runtime.ts b/extensions/memory-core/src/cli-status.runtime.ts index fefb3bcc195c..0f3ffeb1248f 100644 --- a/extensions/memory-core/src/cli-status.runtime.ts +++ b/extensions/memory-core/src/cli-status.runtime.ts @@ -552,7 +552,15 @@ export async function runMemoryStatus( lines.push(` ${issue.severity === "error" ? warn(issue.message) : muted(issue.message)}`); } if (!opts.fix) { - lines.push(` ${muted(`Fix: openclaw memory status --fix --agent ${agentId}`)}`); + // Only a subset of audit issues are repaired by `--fix`; a missing qmd + // index needs a reindex instead, so each hint is gated on the matching + // issue actually being present. + if (audit.issues.some((issue) => issue.fixable)) { + lines.push(` ${muted(`Fix: openclaw memory status --fix --agent ${agentId}`)}`); + } + if (audit.issues.some((issue) => issue.code === "qmd-index-missing")) { + lines.push(` ${muted(`Fix: openclaw memory index --agent ${agentId}`)}`); + } } } if (dreamingAudit?.issues.length) { @@ -562,7 +570,7 @@ export async function runMemoryStatus( for (const issue of dreamingAudit.issues) { lines.push(` ${issue.severity === "error" ? warn(issue.message) : muted(issue.message)}`); } - if (!opts.fix) { + if (!opts.fix && dreamingAudit.issues.some((issue) => issue.fixable)) { lines.push(` ${muted(`Fix: openclaw memory status --fix --agent ${agentId}`)}`); } } diff --git a/extensions/memory-core/src/cli.test.ts b/extensions/memory-core/src/cli.test.ts index bb1ec6bd9f22..fb359ec7b6c8 100644 --- a/extensions/memory-core/src/cli.test.ts +++ b/extensions/memory-core/src/cli.test.ts @@ -1450,6 +1450,34 @@ describe("memory cli", () => { }); }); + it("suggests reindexing instead of --fix when the qmd index is missing", async () => { + await withTempWorkspace(async (workspaceDir) => { + const close = vi.fn(async () => {}); + const missingDbPath = path.join(qmdFixtureRoot, `missing-${qmdCaseId++}.sqlite`); + mockManager({ + probeVectorAvailability: vi.fn(async () => true), + status: () => + makeMemoryStatus({ + backend: "qmd", + provider: "qmd", + model: "qmd", + requestedProvider: "qmd", + workspaceDir, + dbPath: missingDbPath, + }), + close, + }); + + const log = spyRuntimeLogs(defaultRuntime); + await runMemoryCli(["status"]); + + expectLogged(log, "QMD index file is missing."); + expectLogged(log, "Fix: openclaw memory index --agent main"); + expectNotLogged(log, "Fix: openclaw memory status --fix --agent main"); + expect(close).toHaveBeenCalled(); + }); + }); + it("fails index when qmd db file is empty", async () => { const close = vi.fn(async () => {}); const sync = vi.fn(async () => {});