* Parse the session memory file and analyze section sizes
(content: string)
| 132 | * Parse the session memory file and analyze section sizes |
| 133 | */ |
| 134 | function analyzeSectionSizes(content: string): Record<string, number> { |
| 135 | const sections: Record<string, number> = {} |
| 136 | const lines = content.split('\n') |
| 137 | let currentSection = '' |
| 138 | let currentContent: string[] = [] |
| 139 | |
| 140 | for (const line of lines) { |
| 141 | if (line.startsWith('# ')) { |
| 142 | if (currentSection && currentContent.length > 0) { |
| 143 | const sectionContent = currentContent.join('\n').trim() |
| 144 | sections[currentSection] = roughTokenCountEstimation(sectionContent) |
| 145 | } |
| 146 | currentSection = line |
| 147 | currentContent = [] |
| 148 | } else { |
| 149 | currentContent.push(line) |
| 150 | } |
| 151 | } |
| 152 | |
| 153 | if (currentSection && currentContent.length > 0) { |
| 154 | const sectionContent = currentContent.join('\n').trim() |
| 155 | sections[currentSection] = roughTokenCountEstimation(sectionContent) |
| 156 | } |
| 157 | |
| 158 | return sections |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Generate reminders for sections that are too long |
no test coverage detected