* Wrap a Kaos so every `readText` (and `readLines`, which reads via * `readText` in the ACP bridge) rejects with `cause`. Used to simulate the * Zed ACP `fs/readTextFile` "Internal error" path that broke session bootstrap * before AGENTS.md loading was rerouted onto the persistence kaos.
(inner: Kaos, cause: Error)
| 755 | * before AGENTS.md loading was rerouted onto the persistence kaos. |
| 756 | */ |
| 757 | function wrapReadTextWithError(inner: Kaos, cause: Error): Kaos { |
| 758 | return new Proxy(inner, { |
| 759 | get(target, prop, receiver) { |
| 760 | if (prop === 'readText') { |
| 761 | return async () => { |
| 762 | throw cause; |
| 763 | }; |
| 764 | } |
| 765 | if (prop === 'readLines') { |
| 766 | return async function* () { |
| 767 | yield* []; |
| 768 | throw cause; |
| 769 | }; |
| 770 | } |
| 771 | if (prop === 'withCwd') { |
| 772 | return (cwd: string) => wrapReadTextWithError(target.withCwd(cwd), cause); |
| 773 | } |
| 774 | return Reflect.get(target, prop, receiver); |
| 775 | }, |
| 776 | }); |
| 777 | } |
no outgoing calls
no test coverage detected