()
| 609 | return; |
| 610 | } |
| 611 | // fs.cpSync requires Node 16.7+. The project documents Node 18+ as the |
| 612 | // minimum (see Codex install guide), so this is safe. |
| 613 | fs.cpSync(sourceDir, targetDir, { |
| 614 | recursive: true, |
| 615 | force: true, |
| 616 | errorOnExist: false, |
| 617 | filter: (src) => !SKILL_COPY_EXCLUDES.has(path.basename(src)), |
| 618 | }); |
| 619 | } |
| 620 | |
| 621 | function skillTreeDigest(directory) { |
| 622 | const digest = crypto.createHash('sha256'); |
| 623 | function visit(current, relative = '') { |
| 624 | for (const entry of fs.readdirSync(current, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) { |
| 625 | const child = path.join(current, entry.name); |
| 626 | const childRelative = path.join(relative, entry.name).replace(/\\/g, '/'); |
| 627 | if (entry.isSymbolicLink()) throw new Error(`Skill tree contains a symlink: ${childRelative}`); |
| 628 | if (entry.isDirectory()) visit(child, childRelative); |
| 629 | else if (entry.isFile()) { |
| 630 | digest.update(childRelative).update('\0').update(fs.readFileSync(child)).update('\0'); |
| 631 | } |
| 632 | } |
| 633 | } |
no test coverage detected