← Back to PRs

#15307: fix(memory): handle mixed/no-results QMD query output

by MohammadErfan-Jabbari open 2026-02-13 08:07 View on GitHub →
stale size: S
## Summary\n- normalize QMD stdout/stderr by stripping ANSI CSI/OSC sequences before parsing\n- extract balanced JSON array payloads from mixed output (progress + payload)\n- treat `No results found` markers as an empty result set instead of parse failures\n- add parser-focused unit tests for mixed output, no-results markers, and invalid payload paths\n\n## Verification\n- `pnpm exec oxlint src/memory/qmd-query-parser.ts src/memory/qmd-query-parser.test.ts`\n- `pnpm exec tsc -p tsconfig.json --noEmit`\n- `pnpm exec vitest run src/memory/qmd-query-parser.test.ts src/memory/qmd-manager.test.ts --reporter=dot` <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR hardens QMD query parsing by normalizing CLI output (stripping ANSI CSI/OSC sequences and CRs), scanning mixed stdout/stderr for a balanced JSON array payload, and treating known “No results found …” markers as an empty result set instead of a parsing failure. It also adds unit tests covering plain JSON, mixed progress+payload output, no-results markers (stdout/stderr), and the error path when no JSON payload is present. In the codebase, `QmdMemoryManager.search()` shells out to the `qmd` CLI and calls `parseQmdQueryJson(stdout, stderr)` to turn that output into structured results; this change makes that integration resilient to extra non-JSON output emitted by the CLI. <h3>Confidence Score: 5/5</h3> - This PR is safe to merge with minimal risk. - Changes are localized to QMD output parsing and are backed by focused unit tests for the new behaviors (mixed output, no-results markers, and error cases). The parser still throws on truly invalid output and only relaxes behavior for known benign output patterns. - src/memory/qmd-query-parser.ts <sub>Last reviewed commit: 229d6b6</sub> <!-- greptile_other_comments_section --> <sub>(5/5) You can turn off certain types of comments like style [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs