{"record":{"id":"64c8a62d469082ab","repo":"tobi/qmd","slug":"intent-cannot-appear-alone-add-at-least-one-lex-64c8a6","errorCode":null,"errorMessage":"intent: cannot appear alone. Add at least one lex:, vec:, or hyde: line.","messagePattern":"intent: cannot appear alone\\. Add at least one lex:, vec:, or hyde: line\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"src/cli/qmd.ts","lineNumber":2787,"sourceCode":"      }\n      if (/\\r|\\n/.test(text)) {\n        throw new Error(`Line ${line.number} (${type}:) contains a newline. Keep each query on a single line.`);\n      }\n      typed.push({ type, query: text, line: line.number });\n      continue;\n    }\n\n    if (rawLines.length === 1) {\n      // Single plain line -> implicit expand\n      return null;\n    }\n\n    throw new Error(`Line ${line.number} is missing a lex:/vec:/hyde:/intent: prefix. Each line in a query document must start with one.`);\n  }\n\n  // intent: alone is not a valid query — must have at least one search\n  if (intent && typed.length === 0) {\n    throw new Error('intent: cannot appear alone. Add at least one lex:, vec:, or hyde: line.');\n  }\n\n  return typed.length > 0 ? { searches: typed, intent } : null;\n}\n\nfunction search(query: string, opts: OutputOptions): void {\n  const db = getDb();\n\n  // Validate collection filter (supports multiple -c flags)\n  // Use default collections if none specified\n  const collectionNames = resolveCollectionFilter(opts.collection, true);\n\n  // Use large limit for --all, otherwise fetch more than needed and let outputResults filter\n  const fetchLimit = opts.all ? 100000 : Math.max(50, opts.limit * 2);\n  const results = searchFTS(db, query, fetchLimit, collectionSearchFilter(collectionNames));\n\n  // Add context to results\n  const resultsWithContext = results.map(r => ({","sourceCodeStart":2769,"sourceCodeEnd":2805,"githubUrl":"https://github.com/tobi/qmd/blob/dbfd0b4736aeaf761d1a16ca8e424f071df8feb9/src/cli/qmd.ts#L2769-L2805","documentation":"Thrown when a query document contains only an intent: line and no actual search lines. intent: is metadata that sharpens ranking of lex:/vec:/hyde: searches, so it cannot constitute a query by itself.","triggerScenarios":"Calling `qmd query` with a document whose only typed line is intent: (e.g. `intent: find setup instructions` with no lex:/vec:/hyde: lines).","commonSituations":"Assuming intent: is itself a search mode; refactoring a query file and deleting the search lines while keeping intent:.","solutions":["Add at least one lex:, vec:, or hyde: line alongside intent:","Drop intent: and use a plain single-line query instead"],"exampleFix":"# before\nintent: find setup instructions\n# after\nintent: find setup instructions\nlex:setup instructions\nvec:how to set up the project","handlingStrategy":"validation","validationCode":"function hasSearchLine(raw: string): boolean {\n  return raw.split(/\\r?\\n/).some((l) => /^(lex:|vec:|hyde:)/.test(l));\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Treat intent: as ranking hints, never as a standalone query","After editing a query file, confirm at least one lex:/vec:/hyde: line remains"],"tags":["query-document","validation","intent"],"backgroundTag":"query-validation-failed","analyzedSha":"dbfd0b4736aeaf761d1a16ca8e424f071df8feb9","analyzedAt":"2026-08-28T18:07:46.628Z","schemaVersion":2},"datasetVersion":"2026-08-28T21:17:43.275Z"}