MCPcopy Create free account
hub / github.com/Noumena-Network/code / parseAtMentionedFileLines

Function parseAtMentionedFileLines

src/utils/attachments.ts:2843–2859  ·  view source on GitHub ↗
(
  mention: string,
)

Source from the content-addressed store, hash-verified

2841}
2842
2843export function parseAtMentionedFileLines(
2844 mention: string,
2845): AtMentionedFileLines {
2846 // Parse mentions like "file.txt#L10-20", "file.txt#heading", or just "file.txt"
2847 // Supports line ranges (#L10, #L10-20) and strips non-line-range fragments (#heading)
2848 const match = mention.match(/^([^#]+)(?:#L(\d+)(?:-(\d+))?)?(?:#[^#]*)?$/)
2849
2850 if (!match) {
2851 return { filename: mention }
2852 }
2853
2854 const [, filename, lineStartStr, lineEndStr] = match
2855 const lineStart = lineStartStr ? parseInt(lineStartStr, 10) : undefined
2856 const lineEnd = lineEndStr ? parseInt(lineEndStr, 10) : lineStart
2857
2858 return { filename: filename ?? mention, lineStart, lineEnd }
2859}
2860
2861async function getDiagnosticAttachments(
2862 toolUseContext: ToolUseContext,

Callers 1

processAtMentionedFilesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected