ework-daemon 0.4.18 → 0.4.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ework-daemon",
3
- "version": "0.4.18",
3
+ "version": "0.4.19",
4
4
  "description": "Issue-driven AI development daemon. Spawns opencode subprocesses to resolve Gitea issues.",
5
5
  "module": "src/index.ts",
6
6
  "type": "module",
@@ -234,10 +234,17 @@ async function readCapped(stream: ReadableStream<Uint8Array> | null, cap: number
234
234
  }
235
235
 
236
236
  function stripNonJsonPreamble(s: string): string | null {
237
- const i = s.indexOf("[");
238
- const j = s.indexOf("{");
239
- if (i === -1 && j === -1) return null;
240
- if (i === -1) return s.slice(j);
241
- if (j === -1) return s.slice(i);
242
- return s.slice(Math.min(i, j));
237
+ const lines = s.split(/\r?\n/);
238
+ for (let i = 0; i < lines.length; i++) {
239
+ const trimmed = (lines[i] ?? "").trimStart();
240
+ if (!trimmed.startsWith("{") && !trimmed.startsWith("[")) continue;
241
+ const candidate = lines.slice(i).join("\n");
242
+ try {
243
+ JSON.parse(candidate);
244
+ return candidate;
245
+ } catch {
246
+ continue;
247
+ }
248
+ }
249
+ return null;
243
250
  }