readSkillPathsInWindow function
Scans messages for read tool calls on skill manifest paths,
returning the set of SKILL.md paths read in the current window (the
P6 "current-session reads" priority class).
Implementation
Set<String> readSkillPathsInWindow(List<Message> messages, List<Skill> skills) {
if (skills.isEmpty || messages.isEmpty) return const {};
final skillPaths = {for (final skill in skills) skill.filePath};
final reads = <String>{};
for (final message in messages) {
if (message is! AssistantMessage) continue;
for (final block in message.content) {
if (block is! ToolCall || block.name != 'read') continue;
final path = block.arguments['path'];
if (path is String && skillPaths.contains(path)) reads.add(path);
}
}
return reads;
}