{"record":{"id":"79955697c27ef544","repo":"tobi/qmd","slug":"line-line-number-only-one-intent-line-is-allo-799556","errorCode":null,"errorMessage":"Line ${line.number}: only one intent: line is allowed per query document.","messagePattern":"Line (.+?): only one intent: line is allowed per query document\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/qmd.ts","lineNumber":2753,"sourceCode":"  const typed: ExpandedQuery[] = [];\n  let intent: string | undefined;\n\n  for (const line of rawLines) {\n    if (expandRe.test(line.trimmed)) {\n      if (rawLines.length > 1) {\n        throw new Error(`Line ${line.number} starts with expand:, but query documents cannot mix expand with typed lines. Submit a single expand query instead.`);\n      }\n      const text = line.trimmed.replace(expandRe, '').trim();\n      if (!text) {\n        throw new Error('expand: query must include text.');\n      }\n      return null; // treat as standalone expand query\n    }\n\n    // Parse intent: lines\n    if (intentRe.test(line.trimmed)) {\n      if (intent !== undefined) {\n        throw new Error(`Line ${line.number}: only one intent: line is allowed per query document.`);\n      }\n      const text = line.trimmed.replace(intentRe, '').trim();\n      if (!text) {\n        throw new Error(`Line ${line.number}: intent: must include text.`);\n      }\n      intent = text;\n      continue;\n    }\n\n    const match = line.trimmed.match(prefixRe);\n    if (match) {\n      const type = match[1]!.toLowerCase() as 'lex' | 'vec' | 'hyde';\n      const text = line.trimmed.slice(match[0].length).trim();\n      if (!text) {\n        throw new Error(`Line ${line.number} (${type}:) must include text.`);\n      }\n      if (/\\r|\\n/.test(text)) {\n        throw new Error(`Line ${line.number} (${type}:) contains a newline. Keep each query on a single line.`);","sourceCodeStart":2735,"sourceCodeEnd":2771,"githubUrl":"https://github.com/tobi/qmd/blob/dbfd0b4736aeaf761d1a16ca8e424f071df8feb9/src/cli/qmd.ts#L2735-L2771","documentation":"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.","triggerScenarios":"Piping 'lex: install\\nintent: setup\\nintent: help' to `qmd query`.","commonSituations":"Editing a saved query document and duplicating the intent line; merging two query documents.","solutions":["Delete the duplicate intent: line","Merge both intents into one descriptive line"],"exampleFix":"# before\nlex: install\nintent: setup\nintent: help\n# after\nlex: install\nintent: setup and installation help","handlingStrategy":"validation","validationCode":"if ((doc.match(/^\\s*intent:/gm) || []).length > 1) throw new Error('multiple intent: lines');","typeGuard":"const singleIntentOnly = (doc: string) => (doc.match(/^\\s*intent:/gm) || []).length <= 1;","tryCatchPattern":null,"preventionTips":["Keep saved query documents under lint; check intent: count before piping to qmd query"],"tags":["query","cli","query-syntax"],"backgroundTag":"query-syntax-validation-failed","analyzedSha":"dbfd0b4736aeaf761d1a16ca8e424f071df8feb9","analyzedAt":"2026-08-28T18:07:46.628Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}