tobi/qmd · error · Error
Line ${line.number} starts with expand:, but query documents
Error message
Line ${line.number} starts with expand:, but query documents cannot mix expand with typed lines. Submit a single expand query instead. What it means
Thrown by the query-document parser in the CLI when a line starts with 'expand:' but the document has more than one line. expand: queries are standalone: they cannot be mixed with lex:/vec:/hyde:/intent: lines in one document.
Source
Thrown at src/cli/qmd.ts:2741
function parseStructuredQuery(query: string): ParsedStructuredQuery | null {
const rawLines = query.split('\n').map((line, idx) => ({
raw: line,
trimmed: line.trim(),
number: idx + 1,
})).filter(line => line.trimmed.length > 0);
if (rawLines.length === 0) return null;
const prefixRe = /^(lex|vec|hyde):\s*/i;
const expandRe = /^expand:\s*/i;
const intentRe = /^intent:\s*/i;
const typed: ExpandedQuery[] = [];
let intent: string | undefined;
for (const line of rawLines) {
if (expandRe.test(line.trimmed)) {
if (rawLines.length > 1) {
throw new Error(`Line ${line.number} starts with expand:, but query documents cannot mix expand with typed lines. Submit a single expand query instead.`);
}
const text = line.trimmed.replace(expandRe, '').trim();
if (!text) {
throw new Error('expand: query must include text.');
}
return null; // treat as standalone expand query
}
// Parse intent: lines
if (intentRe.test(line.trimmed)) {
if (intent !== undefined) {
throw new Error(`Line ${line.number}: only one intent: line is allowed per query document.`);
}
const text = line.trimmed.replace(intentRe, '').trim();
if (!text) {
throw new Error(`Line ${line.number}: intent: must include text.`);
}
intent = text;View on GitHub (pinned to dbfd0b4736)
Solutions
- Delete the other lines and submit just the single expand: line
- Or drop the expand: line and keep the typed lex:/vec:/hyde: lines
Example fix
# before printf 'expand: machine setup\nlex: install' | qmd query # after printf 'expand: machine setup' | qmd query
Defensive patterns
Strategy: validation
Validate before calling
const lines = doc.split('\n').filter(l => l.trim());
if (/^\s*expand:/i.test(doc) && lines.length > 1) throw new Error('expand: must be the only line'); Type guard
const isStandaloneExpand = (doc: string) => /^\s*expand:/i.test(doc) && doc.split('\n').filter(l => l.trim()).length === 1; Prevention
- Treat expand: as a one-line query mode; never concatenate it with typed lines
When it happens
Trigger: Piping or typing a query document like 'expand: machine setup\nlex: install' to `qmd query`.
Common situations: Graduating a typed query to expansion and forgetting to delete the other lines; scripts concatenating query lines.
Related errors
- expand: query must include text.
- Line ${line.number}: only one intent: line is allowed per qu
- Line ${line.number}: intent: must include text.
- Line ${line.number} (${type}:) must include text.
- Line ${line.number} (${type}:) contains a newline. Keep each
AI-assisted analysis of tobi/qmd@dbfd0b4736 (2026-08-28).
Data as JSON: /api/errors/da5fa350c7dd249d.
Report an issue: GitHub.