tobi/qmd · error · Error

Line ${line.number}: intent: must include text.

Error message

Line ${line.number}: intent: must include text.

What it means

Thrown by the CLI query-document parser when an intent: line carries no text. Same rule as the bench parser: every prefixed line must include content.

Source

Thrown at src/cli/qmd.ts:2757

    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.`);
      }
      typed.push({ type, query: text, line: line.number });
      continue;
    }

View on GitHub (pinned to dbfd0b4736)

Solutions

  1. Add text after intent: or delete the line
  2. Quote and default variables in scripts: "intent: ${INTENT:-general help}"

Example fix

# before
lex: install
intent:
# after
lex: install
intent: find installation help
Defensive patterns

Strategy: validation

Validate before calling

if (/^\s*intent:\s*$/m.test(doc)) throw new Error('empty intent: line');

Type guard

const noEmptyIntentLine = (doc: string) => !/^\s*intent:\s*$/m.test(doc);

Prevention

When it happens

Trigger: Piping 'intent:' with nothing after it as part of a query document to `qmd query`.

Common situations: Typos; empty shell variables interpolated after the prefix.

Related errors


AI-assisted analysis of tobi/qmd@dbfd0b4736 (2026-08-28). Data as JSON: /api/errors/219b6e463df49e4e. Report an issue: GitHub.