(text: string, out: Set<string>)
| 108 | } |
| 109 | |
| 110 | function extractRecalledDocIds(text: string, out: Set<string>): void { |
| 111 | const START = '--- [teamai:recall:start] ---'; |
| 112 | const END = '--- [teamai:recall:end] ---'; |
| 113 | const filePattern = /^File:\s*(.+)$/gm; |
| 114 | |
| 115 | let searchFrom = 0; |
| 116 | while (true) { |
| 117 | const startIdx = text.indexOf(START, searchFrom); |
| 118 | if (startIdx === -1) break; |
| 119 | |
| 120 | const endIdx = text.indexOf(END, startIdx + START.length); |
| 121 | if (endIdx === -1) break; |
| 122 | |
| 123 | const region = text.slice(startIdx + START.length, endIdx); |
| 124 | filePattern.lastIndex = 0; |
| 125 | |
| 126 | let match: RegExpExecArray | null; |
| 127 | while ((match = filePattern.exec(region)) !== null) { |
| 128 | const filePath = match[1].trim(); |
| 129 | const docId = path.basename(filePath).replace(/\.md$/i, ''); |
| 130 | if (isValidDocId(docId)) out.add(docId); |
| 131 | } |
| 132 | |
| 133 | searchFrom = endIdx + END.length; |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | function extractReferencedDocIds(text: string, out: Set<string>): void { |
| 138 | // Case-insensitive; accept smart-punctuation variants of both delimiters. |
no test coverage detected