tobi/qmd · error · Error
Line ${line.number}: only one intent: line is allowed per qu
Error message
Line ${line.number}: only one intent: line is allowed per query document. What it means
Thrown by the CLI query-document parser when a query document contains a second 'intent:' line. Only one intent annotation is allowed per document; the first one wins and any later intent: line throws.
Source
Thrown at src/cli/qmd.ts:2753
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;
continue;
}
const match = line.trimmed.match(prefixRe);
if (match) {
const type = match[1]!.toLowerCase() as 'lex' | 'vec' | 'hyde';
const text = line.trimmed.slice(match[0].length).trim();
if (!text) {
throw new Error(`Line ${line.number} (${type}:) must include text.`);
}
if (/\r|\n/.test(text)) {
throw new Error(`Line ${line.number} (${type}:) contains a newline. Keep each query on a single line.`);View on GitHub (pinned to dbfd0b4736)
Solutions
- Delete the duplicate intent: line
- Merge both intents into one descriptive line
Example fix
# before lex: install intent: setup intent: help # after lex: install intent: setup and installation help
Defensive patterns
Strategy: validation
Validate before calling
if ((doc.match(/^\s*intent:/gm) || []).length > 1) throw new Error('multiple intent: lines'); Type guard
const singleIntentOnly = (doc: string) => (doc.match(/^\s*intent:/gm) || []).length <= 1;
Prevention
- Keep saved query documents under lint; check intent: count before piping to qmd query
When it happens
Trigger: Piping 'lex: install\nintent: setup\nintent: help' to `qmd query`.
Common situations: Editing a saved query document and duplicating the intent line; merging two query documents.
Related errors
- Line ${line.number} starts with expand:, but query documents
- expand: query must include text.
- 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/79955697c27ef544.
Report an issue: GitHub.