| 106 | } |
| 107 | |
| 108 | function relativeSafe(from: string, to: string): string { |
| 109 | const fromParts = from.split(/[/\\]+/).filter(Boolean) |
| 110 | const toParts = to.split(/[/\\]+/).filter(Boolean) |
| 111 | let common = 0 |
| 112 | while ( |
| 113 | common < fromParts.length && |
| 114 | common < toParts.length && |
| 115 | fromParts[common] === toParts[common] |
| 116 | ) { |
| 117 | common += 1 |
| 118 | } |
| 119 | const up = fromParts.length - common |
| 120 | const down = toParts.slice(common) |
| 121 | return [...Array(up).fill('..'), ...down].join('/') |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Collects AGENTS.md / .agents/ memory files for the current project and user. |