()
| 26 | |
| 27 | export function findRepoRoot(): string { |
| 28 | let dir = import.meta.dirname; |
| 29 | for (let i = 0; i < 20; i++) { |
| 30 | const pkgPath = path.join(dir, 'package.json'); |
| 31 | if (fs.existsSync(pkgPath)) { |
| 32 | try { |
| 33 | const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8')); |
| 34 | if (pkg.name === 'kilocode-monorepo') return dir; |
| 35 | } catch { |
| 36 | // Not valid JSON, keep walking |
| 37 | } |
| 38 | } |
| 39 | const parent = path.dirname(dir); |
| 40 | if (parent === dir) break; |
| 41 | dir = parent; |
| 42 | } |
| 43 | throw new Error("Could not find repo root (package.json with name 'kilocode-monorepo')"); |
| 44 | } |
| 45 | |
| 46 | export function probePort(port: number, timeoutMs = 500): Promise<boolean> { |
| 47 | return new Promise(resolve => { |
| 48 | const socket = new net.Socket(); |
no test coverage detected