Text Find

Find a substring or pattern in a text document. Returns position with surrounding context. Deterministic — use this instead of asking the LLM to find substrings.

bdambrosio 596b464 3 files · 5.7 KB Updated

File contents

text-find

Locate patterns or substrings in text and return all matches with context.

Behavior

  • Case-sensitive by default.
  • Supports standard Python regex syntax in pattern.
  • Returns every match (not just the first), with line/character position and the surrounding lines.
  • Returns an empty result if no matches — not an error.

When to use vs assess / process_text

  • text-find — exact substring or regex match. Deterministic. No LLM cost.
  • assess — natural-language predicate (semantic match). LLM-backed.
  • process_text — open-ended transformation with an instruction.

If you want "does this contain the literal string X?" → text-find. If you want "does this contain mention of X?" (paraphrases count) → assess.

Examples

{"thought": "find every TODO in the document", "tool": "text-find", "source": "$step1", "pattern": "TODO"}
{"thought": "locate error lines mentioning a timeout", "tool": "text-find", "source": "$step1", "pattern": "ERROR.*timeout", "context_lines": 3}

bdambrosio/cognitive_workbench/tree/main/src/tools/text-find commit 596b464ebb

Frequently asked questions

npx skillmds@latest add bdambrosio/text-find