@cccarv82/freya 1.0.17 → 1.0.18
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/web-ui.js +33 -9
- package/cli/web.js +7 -2
- package/package.json +1 -1
package/cli/web-ui.js
CHANGED
|
@@ -205,7 +205,10 @@
|
|
|
205
205
|
body: body ? JSON.stringify(body) : undefined
|
|
206
206
|
});
|
|
207
207
|
const json = await res.json();
|
|
208
|
-
if (!res.ok)
|
|
208
|
+
if (!res.ok) {
|
|
209
|
+
const detail = json.details ? ('\n' + json.details) : '';
|
|
210
|
+
throw new Error((json.error || 'Request failed') + detail);
|
|
211
|
+
}
|
|
209
212
|
return json;
|
|
210
213
|
}
|
|
211
214
|
|
|
@@ -310,6 +313,8 @@
|
|
|
310
313
|
setOut(r.output);
|
|
311
314
|
setLast(null);
|
|
312
315
|
await refreshReports();
|
|
316
|
+
// Auto health after init
|
|
317
|
+
try { await doHealth(); } catch {}
|
|
313
318
|
setPill('ok', 'init ok');
|
|
314
319
|
} catch (e) {
|
|
315
320
|
setPill('err', 'init failed');
|
|
@@ -327,6 +332,8 @@
|
|
|
327
332
|
setOut(r.output);
|
|
328
333
|
setLast(null);
|
|
329
334
|
await refreshReports();
|
|
335
|
+
// Auto health after update
|
|
336
|
+
try { await doHealth(); } catch {}
|
|
330
337
|
setPill('ok', 'update ok');
|
|
331
338
|
} catch (e) {
|
|
332
339
|
setPill('err', 'update failed');
|
|
@@ -505,6 +512,7 @@
|
|
|
505
512
|
try {
|
|
506
513
|
if (!state.lastPlan) {
|
|
507
514
|
setPill('err', 'no plan');
|
|
515
|
+
setOut('## Apply failed\n\nNo plan available. Run **Save + Process (Agents)** first.');
|
|
508
516
|
return;
|
|
509
517
|
}
|
|
510
518
|
setPill('run', 'applying…');
|
|
@@ -522,6 +530,8 @@
|
|
|
522
530
|
setPill('ok', 'applied');
|
|
523
531
|
setTimeout(() => setPill('ok', 'idle'), 800);
|
|
524
532
|
} catch (e) {
|
|
533
|
+
const msg = (e && e.message) ? e.message : String(e);
|
|
534
|
+
setOut('## Apply failed\n\n' + msg);
|
|
525
535
|
setPill('err', 'apply failed');
|
|
526
536
|
}
|
|
527
537
|
}
|
|
@@ -531,21 +541,35 @@
|
|
|
531
541
|
$('chipPort').textContent = location.host;
|
|
532
542
|
loadLocal();
|
|
533
543
|
|
|
534
|
-
// Load persisted settings from the workspace
|
|
544
|
+
// Load persisted settings from the workspace + bootstrap (auto-init + auto-health)
|
|
535
545
|
(async () => {
|
|
546
|
+
let defaults = null;
|
|
536
547
|
try {
|
|
537
|
-
|
|
538
|
-
if (
|
|
539
|
-
$('dir').value =
|
|
540
|
-
$('sidePath').textContent =
|
|
548
|
+
defaults = await api('/api/defaults', { dir: dirOrDefault() });
|
|
549
|
+
if (defaults && defaults.workspaceDir) {
|
|
550
|
+
$('dir').value = defaults.workspaceDir;
|
|
551
|
+
$('sidePath').textContent = defaults.workspaceDir;
|
|
541
552
|
}
|
|
542
|
-
if (
|
|
543
|
-
$('discord').value =
|
|
544
|
-
$('teams').value =
|
|
553
|
+
if (defaults && defaults.settings) {
|
|
554
|
+
$('discord').value = defaults.settings.discordWebhookUrl || '';
|
|
555
|
+
$('teams').value = defaults.settings.teamsWebhookUrl || '';
|
|
545
556
|
}
|
|
546
557
|
} catch (e) {
|
|
547
558
|
// ignore
|
|
548
559
|
}
|
|
560
|
+
|
|
561
|
+
// If workspace isn't initialized yet, auto-init (reduces clicks)
|
|
562
|
+
try {
|
|
563
|
+
if (defaults && defaults.workspaceOk === false) {
|
|
564
|
+
setPill('run', 'auto-init…');
|
|
565
|
+
await doInit();
|
|
566
|
+
// After init, run health automatically
|
|
567
|
+
await doHealth();
|
|
568
|
+
}
|
|
569
|
+
} catch (e) {
|
|
570
|
+
// doInit/doHealth already surfaced errors
|
|
571
|
+
}
|
|
572
|
+
|
|
549
573
|
refreshReports();
|
|
550
574
|
})();
|
|
551
575
|
|
package/cli/web.js
CHANGED
|
@@ -710,7 +710,8 @@ async function cmdWeb({ port, dir, open, dev }) {
|
|
|
710
710
|
if (req.url === '/api/defaults') {
|
|
711
711
|
const settings = readSettings(workspaceDir);
|
|
712
712
|
const reports = listReports(workspaceDir).slice(0, 20);
|
|
713
|
-
|
|
713
|
+
const workspaceOk = looksLikeFreyaWorkspace(workspaceDir);
|
|
714
|
+
return safeJson(res, 200, { workspaceDir, workspaceOk, settings, reports });
|
|
714
715
|
}
|
|
715
716
|
|
|
716
717
|
if (req.url === '/api/settings/save') {
|
|
@@ -917,7 +918,11 @@ async function cmdWeb({ port, dir, open, dev }) {
|
|
|
917
918
|
try {
|
|
918
919
|
plan = JSON.parse(jsonText);
|
|
919
920
|
} catch (e) {
|
|
920
|
-
return safeJson(res, 400, {
|
|
921
|
+
return safeJson(res, 400, {
|
|
922
|
+
error: 'Plan is not valid JSON',
|
|
923
|
+
details: (e && e.message) ? e.message : String(e),
|
|
924
|
+
hint: 'O planner precisa retornar APENAS JSON. Se vier com texto extra, revise o prompt ou use apenas o bloco JSON.'
|
|
925
|
+
});
|
|
921
926
|
}
|
|
922
927
|
|
|
923
928
|
const actions = Array.isArray(plan.actions) ? plan.actions : [];
|