docs(cli): improve memory command examples (#31803)
Merged via squash. Prepared head SHA: 15dcda3027f836e3f780533f7dc6d05c81c6b65a Co-authored-by: JasonOA888 <101583541+JasonOA888@users.noreply.github.com> Co-authored-by: altaywtf <9790196+altaywtf@users.noreply.github.com> Reviewed-by: @altaywtf
This commit is contained in:
@@ -113,6 +113,29 @@ describe("memory cli", () => {
|
||||
await program.parseAsync(["memory", ...args], { from: "user" });
|
||||
}
|
||||
|
||||
function captureHelpOutput(command: Command | undefined) {
|
||||
let output = "";
|
||||
const writeSpy = vi.spyOn(process.stdout, "write").mockImplementation(((
|
||||
chunk: string | Uint8Array,
|
||||
) => {
|
||||
output += String(chunk);
|
||||
return true;
|
||||
}) as typeof process.stdout.write);
|
||||
try {
|
||||
command?.outputHelp();
|
||||
return output;
|
||||
} finally {
|
||||
writeSpy.mockRestore();
|
||||
}
|
||||
}
|
||||
|
||||
function getMemoryHelpText() {
|
||||
const program = new Command();
|
||||
registerMemoryCli(program);
|
||||
const memoryCommand = program.commands.find((command) => command.name() === "memory");
|
||||
return captureHelpOutput(memoryCommand);
|
||||
}
|
||||
|
||||
async function withQmdIndexDb(content: string, run: (dbPath: string) => Promise<void>) {
|
||||
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "memory-cli-qmd-index-"));
|
||||
const dbPath = path.join(tmpDir, "index.sqlite");
|
||||
@@ -220,6 +243,17 @@ describe("memory cli", () => {
|
||||
expect(hasLoggedInactiveSecretDiagnostic(log)).toBe(true);
|
||||
});
|
||||
|
||||
it("documents memory help examples", () => {
|
||||
const helpText = getMemoryHelpText();
|
||||
|
||||
expect(helpText).toContain("openclaw memory status --deep");
|
||||
expect(helpText).toContain("Probe embedding provider readiness.");
|
||||
expect(helpText).toContain('openclaw memory search "meeting notes"');
|
||||
expect(helpText).toContain("Quick search using positional query.");
|
||||
expect(helpText).toContain('openclaw memory search --query "deployment" --max-results 20');
|
||||
expect(helpText).toContain("Limit results for focused troubleshooting.");
|
||||
});
|
||||
|
||||
it("prints vector error when unavailable", async () => {
|
||||
const close = vi.fn(async () => {});
|
||||
mockManager({
|
||||
|
||||
Reference in New Issue
Block a user