(sourceDir, specialisms)
| 194 | } |
| 195 | |
| 196 | function discoverProtocols(sourceDir, specialisms) { |
| 197 | const protocolsDir = path.join(sourceDir, 'protocols'); |
| 198 | const ids = new Set(); |
| 199 | |
| 200 | if (fs.existsSync(protocolsDir)) { |
| 201 | for (const entry of fs.readdirSync(protocolsDir, { withFileTypes: true })) { |
| 202 | if (entry.isDirectory()) ids.add(entry.name); |
| 203 | } |
| 204 | } |
| 205 | for (const s of specialisms) { |
| 206 | if (s.protocol) ids.add(s.protocol); |
| 207 | } |
| 208 | |
| 209 | const items = []; |
| 210 | for (const id of ids) { |
| 211 | const indexPath = path.join(protocolsDir, id, 'index.yaml'); |
| 212 | const fm = fs.existsSync(indexPath) ? readYamlFrontmatter(indexPath) : {}; |
| 213 | items.push({ |
| 214 | id, |
| 215 | title: fm.title || null, |
| 216 | has_baseline: fs.existsSync(indexPath), |
| 217 | path: `protocols/${id}/` |
| 218 | }); |
| 219 | } |
| 220 | return items.sort((a, b) => a.id.localeCompare(b.id)); |
| 221 | } |
| 222 | |
| 223 | // ── Idempotency lint ──────────────────────────────────────────────── |
| 224 | // |
no test coverage detected