@cccarv82/freya 3.8.2 → 3.8.4
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/cli/retroactive-ingest.js +24 -3
- package/package.json +1 -1
|
@@ -117,10 +117,20 @@ function extractFirstJsonObject(text) {
|
|
|
117
117
|
const start = text.indexOf('{');
|
|
118
118
|
if (start === -1) return null;
|
|
119
119
|
let depth = 0;
|
|
120
|
+
let inString = false;
|
|
121
|
+
let escape = false;
|
|
120
122
|
for (let i = start; i < text.length; i++) {
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
const ch = text[i];
|
|
124
|
+
if (escape) { escape = false; continue; }
|
|
125
|
+
if (ch === '\\' && inString) { escape = true; continue; }
|
|
126
|
+
if (ch === '"') { inString = !inString; continue; }
|
|
127
|
+
if (inString) continue;
|
|
128
|
+
if (ch === '{') depth++;
|
|
129
|
+
else if (ch === '}') { depth--; if (depth === 0) return text.slice(start, i + 1); }
|
|
123
130
|
}
|
|
131
|
+
// If brace matching failed, try a greedy approach — find the last }
|
|
132
|
+
const lastBrace = text.lastIndexOf('}');
|
|
133
|
+
if (lastBrace > start) return text.slice(start, lastBrace + 1);
|
|
124
134
|
return null;
|
|
125
135
|
}
|
|
126
136
|
|
|
@@ -304,7 +314,7 @@ IMPORTANTE: Extraia APENAS informações explícitas do log. NÃO invente dados.
|
|
|
304
314
|
r = await run(sc, sa, workspaceDir, agentEnv);
|
|
305
315
|
try { fs.unlinkSync(tmpFile); } catch { }
|
|
306
316
|
} else {
|
|
307
|
-
const { cmd: sc, args: sa } = copilotSpawnArgs(copilotResolved, [...copilotExtra, '-p', fullPrompt]);
|
|
317
|
+
const { cmd: sc, args: sa } = copilotSpawnArgs(copilotResolved, [...copilotExtra, '--allow-all-tools', '-p', fullPrompt]);
|
|
308
318
|
r = await run(sc, sa, workspaceDir, agentEnv);
|
|
309
319
|
}
|
|
310
320
|
|
|
@@ -330,6 +340,17 @@ IMPORTANTE: Extraia APENAS informações explícitas do log. NÃO invente dados.
|
|
|
330
340
|
} catch {
|
|
331
341
|
try { plan = JSON.parse(escapeJsonControlChars(jsonText)); } catch {
|
|
332
342
|
totalErrors++;
|
|
343
|
+
if (totalErrors <= 2) {
|
|
344
|
+
console.log(`\n ⚠ JSON parse diagnostic for ${date}:`);
|
|
345
|
+
console.log(` Raw output length: ${out.length} chars`);
|
|
346
|
+
console.log(` Raw output (first 300 chars): ${out.slice(0, 300)}`);
|
|
347
|
+
console.log(` Raw output (last 200 chars): ${out.slice(-200)}`);
|
|
348
|
+
console.log(` Extracted JSON length: ${(jsonText || '').length}`);
|
|
349
|
+
console.log(` Extracted JSON (last 200 chars): ${(jsonText || '').slice(-200)}`);
|
|
350
|
+
try { JSON.parse(jsonText); } catch (parseErr) {
|
|
351
|
+
console.log(` Parse error: ${parseErr.message}`);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
333
354
|
process.stdout.write(`\r [${i + 1}/${files.length}] ${date} — ❌ invalid JSON `);
|
|
334
355
|
continue;
|
|
335
356
|
}
|
package/package.json
CHANGED