()
| 65 | * back. This keeps client.expectedVersion and daemon.VERSION coherent. |
| 66 | */ |
| 67 | export function readVersionString(): string { |
| 68 | const env = process.env.DESIGN_DAEMON_VERSION; |
| 69 | if (env) return env; |
| 70 | const candidates = [ |
| 71 | // Compiled binary: design/dist/design lives alongside design/dist/.version |
| 72 | path.join(path.dirname(process.execPath), ".version"), |
| 73 | // Dev: design/src/* → repo root is two levels up |
| 74 | path.join(import.meta.dir, "..", "..", "VERSION"), |
| 75 | // Defensive: design/dist sibling of source tree |
| 76 | path.join(import.meta.dir, "..", "dist", ".version"), |
| 77 | ]; |
| 78 | for (const p of candidates) { |
| 79 | try { |
| 80 | const v = fs.readFileSync(p, "utf-8").trim(); |
| 81 | if (v) return v; |
| 82 | } catch { |
| 83 | // try next |
| 84 | } |
| 85 | } |
| 86 | return "unknown"; |
| 87 | } |
| 88 | |
| 89 | export function readStateFile(stateFile: string = resolveStateFilePath()): DaemonState | null { |
| 90 | try { |
no outgoing calls
no test coverage detected