MCPcopy Create free account
hub / github.com/IBM/mcp-cli / parse_inline_refs

Function parse_inline_refs

src/mcp_cli/chat/attachments.py:342–356  ·  view source on GitHub ↗

Extract ``@file:path`` references from message text. Returns ------- (cleaned_text, list_of_paths) *cleaned_text* has the ``@file:...`` tokens removed.

(text: str)

Source from the content-addressed store, hash-verified

340
341
342def parse_inline_refs(text: str) -> tuple[str, list[str]]:
343 """Extract ``@file:path`` references from message text.
344
345 Returns
346 -------
347 (cleaned_text, list_of_paths)
348 *cleaned_text* has the ``@file:...`` tokens removed.
349 """
350 paths = _INLINE_REF_RE.findall(text)
351 if not paths:
352 return text, []
353 cleaned = _INLINE_REF_RE.sub("", text).strip()
354 # Collapse multiple spaces left by removal
355 cleaned = re.sub(r" +", " ", cleaned)
356 return cleaned, paths
357
358
359# ------------------------------------------------------------------ #

Callers 7

_run_enhanced_chat_loopFunction · 0.90
test_single_refMethod · 0.90
test_multiple_refsMethod · 0.90
test_no_refsMethod · 0.90
test_empty_stringMethod · 0.90
test_collapses_spacesMethod · 0.90

Calls

no outgoing calls

Tested by 6

test_single_refMethod · 0.72
test_multiple_refsMethod · 0.72
test_no_refsMethod · 0.72
test_empty_stringMethod · 0.72
test_collapses_spacesMethod · 0.72