@cccarv82/freya 1.0.44 → 1.0.45
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 +37 -0
- package/cli/web.js +40 -0
- package/package.json +4 -2
package/cli/web-ui.js
CHANGED
|
@@ -240,6 +240,28 @@
|
|
|
240
240
|
}
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
+
async function askFreya() {
|
|
244
|
+
const input = $('inboxText');
|
|
245
|
+
const query = input ? input.value.trim() : '';
|
|
246
|
+
if (!query) {
|
|
247
|
+
setPill('err', 'digite uma pergunta');
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
chatAppend('user', query);
|
|
252
|
+
setPill('run', 'pesquisando…');
|
|
253
|
+
try {
|
|
254
|
+
const sessionId = ensureChatSession();
|
|
255
|
+
const r = await api('/api/chat/ask', { dir: dirOrDefault(), sessionId, query });
|
|
256
|
+
const answer = r && r.answer ? r.answer : 'Não encontrei registro';
|
|
257
|
+
chatAppend('assistant', answer, { markdown: true });
|
|
258
|
+
setPill('ok', 'pronto');
|
|
259
|
+
} catch (e) {
|
|
260
|
+
setPill('err', 'falhou');
|
|
261
|
+
chatAppend('assistant', String(e && e.message ? e.message : e));
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
243
265
|
function setOut(text) {
|
|
244
266
|
state.lastText = text || '';
|
|
245
267
|
const el = $('reportPreview');
|
|
@@ -713,6 +735,19 @@
|
|
|
713
735
|
}
|
|
714
736
|
}
|
|
715
737
|
|
|
738
|
+
async function rebuildIndex() {
|
|
739
|
+
try {
|
|
740
|
+
setPill('run', 'indexing…');
|
|
741
|
+
const r = await api('/api/index/rebuild', { dir: dirOrDefault() });
|
|
742
|
+
setOut('## Index rebuild\n\n' + (r.output || 'ok'));
|
|
743
|
+
setPill('ok', 'indexed');
|
|
744
|
+
setTimeout(() => setPill('ok', 'pronto'), 800);
|
|
745
|
+
} catch (e) {
|
|
746
|
+
setPill('err', 'index failed');
|
|
747
|
+
setOut(String(e && e.message ? e.message : e));
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
716
751
|
async function reloadSlugRules() {
|
|
717
752
|
try {
|
|
718
753
|
const r = await api('/api/project-slug-map/get', { dir: dirOrDefault() });
|
|
@@ -1020,6 +1055,7 @@
|
|
|
1020
1055
|
window.reloadSlugRules = reloadSlugRules;
|
|
1021
1056
|
window.saveSlugRules = saveSlugRules;
|
|
1022
1057
|
window.exportObsidian = exportObsidian;
|
|
1058
|
+
window.rebuildIndex = rebuildIndex;
|
|
1023
1059
|
window.renderReportsList = renderReportsList;
|
|
1024
1060
|
window.copyOut = copyOut;
|
|
1025
1061
|
window.copyPath = copyPath;
|
|
@@ -1035,4 +1071,5 @@
|
|
|
1035
1071
|
window.applyPlan = applyPlan;
|
|
1036
1072
|
window.runSuggestedReports = runSuggestedReports;
|
|
1037
1073
|
window.exportChatObsidian = exportChatObsidian;
|
|
1074
|
+
window.askFreya = askFreya;
|
|
1038
1075
|
})();
|
package/cli/web.js
CHANGED
|
@@ -5,6 +5,8 @@ const fs = require('fs');
|
|
|
5
5
|
const path = require('path');
|
|
6
6
|
const crypto = require('crypto');
|
|
7
7
|
const { spawn } = require('child_process');
|
|
8
|
+
const { searchWorkspace } = require('../scripts/lib/search-utils');
|
|
9
|
+
const { searchIndex } = require('../scripts/lib/index-utils');
|
|
8
10
|
|
|
9
11
|
function guessNpmCmd() {
|
|
10
12
|
// We'll execute via cmd.exe on Windows for reliability.
|
|
@@ -840,6 +842,9 @@ function buildHtml(safeDefault) {
|
|
|
840
842
|
<div class="panelBody">
|
|
841
843
|
<div class="help">Logs ficam em <code>logs/</code> e debug traces em <code>.debuglogs/</code> dentro da workspace.</div>
|
|
842
844
|
<div class="help">Use <b>Open file</b> / <b>Copy path</b> no Preview para abrir/compartilhar o relatório selecionado.</div>
|
|
845
|
+
<div class="stack" style="margin-top:10px">
|
|
846
|
+
<button class="btn" onclick="rebuildIndex()">Rebuild search index</button>
|
|
847
|
+
</div>
|
|
843
848
|
</div>
|
|
844
849
|
</div>
|
|
845
850
|
</div>
|
|
@@ -871,6 +876,7 @@ function buildHtml(safeDefault) {
|
|
|
871
876
|
<button class="btn primary" type="button" onclick="saveAndPlan()">Salvar + Processar (Agents)</button>
|
|
872
877
|
<button class="btn" type="button" onclick="runSuggestedReports()">Rodar relatórios sugeridos</button>
|
|
873
878
|
<button class="btn" type="button" onclick="exportChatObsidian()">Exportar conversa (Obsidian)</button>
|
|
879
|
+
<button class="btn" type="button" onclick="askFreya()">Perguntar à Freya</button>
|
|
874
880
|
</div>
|
|
875
881
|
|
|
876
882
|
<div class="composerToggles">
|
|
@@ -1606,6 +1612,40 @@ async function cmdWeb({ port, dir, open, dev }) {
|
|
|
1606
1612
|
return safeJson(res, r.code === 0 ? 200 : 400, r.code === 0 ? { ok: true, output: out } : { error: out || 'export failed', output: out });
|
|
1607
1613
|
}
|
|
1608
1614
|
|
|
1615
|
+
if (req.url === '/api/index/rebuild') {
|
|
1616
|
+
const r = await run(npmCmd, ['run', 'build-index'], workspaceDir);
|
|
1617
|
+
const out = (r.stdout + r.stderr).trim();
|
|
1618
|
+
return safeJson(res, r.code === 0 ? 200 : 400, r.code === 0 ? { ok: true, output: out } : { error: out || 'index rebuild failed', output: out });
|
|
1619
|
+
}
|
|
1620
|
+
|
|
1621
|
+
if (req.url === '/api/chat/ask') {
|
|
1622
|
+
const sessionId = String(payload.sessionId || '').trim();
|
|
1623
|
+
const query = String(payload.query || '').trim();
|
|
1624
|
+
if (!query) return safeJson(res, 400, { error: 'Missing query' });
|
|
1625
|
+
|
|
1626
|
+
const indexMatches = searchIndex(workspaceDir, query, { limit: 8 });
|
|
1627
|
+
const matches = indexMatches.length
|
|
1628
|
+
? indexMatches
|
|
1629
|
+
: searchWorkspace(workspaceDir, query, { limit: 8 });
|
|
1630
|
+
if (!matches.length) {
|
|
1631
|
+
return safeJson(res, 200, { ok: true, sessionId, answer: 'Não encontrei registro', matches: [] });
|
|
1632
|
+
}
|
|
1633
|
+
|
|
1634
|
+
const lines = [];
|
|
1635
|
+
lines.push(`Encontrei ${matches.length} registro(s):`);
|
|
1636
|
+
for (const m of matches) {
|
|
1637
|
+
const parts = [];
|
|
1638
|
+
if (m.date) parts.push(`**${m.date}**`);
|
|
1639
|
+
if (m.file) parts.push('`' + m.file + '`');
|
|
1640
|
+
const prefix = parts.length ? parts.join(' — ') + ':' : '';
|
|
1641
|
+
const snippet = m.snippet ? String(m.snippet).trim() : '';
|
|
1642
|
+
lines.push(`- ${prefix} ${snippet}`);
|
|
1643
|
+
}
|
|
1644
|
+
|
|
1645
|
+
const answer = lines.join('\n');
|
|
1646
|
+
return safeJson(res, 200, { ok: true, sessionId, answer, matches });
|
|
1647
|
+
}
|
|
1648
|
+
|
|
1609
1649
|
// Chat persistence (per session)
|
|
1610
1650
|
if (req.url === '/api/chat/append') {
|
|
1611
1651
|
const sessionId = String(payload.sessionId || '').trim();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cccarv82/freya",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.45",
|
|
4
4
|
"description": "Personal AI Assistant with local-first persistence",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"health": "node scripts/validate-data.js",
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"status": "node scripts/generate-executive-report.js",
|
|
12
12
|
"blockers": "node scripts/generate-blockers-report.js",
|
|
13
13
|
"export-obsidian": "node scripts/export-obsidian.js",
|
|
14
|
-
"
|
|
14
|
+
"build-index": "node scripts/index/build-index.js",
|
|
15
|
+
"update-index": "node scripts/index/update-index.js",
|
|
16
|
+
"test": "node tests/unit/test-package-config.js && node tests/unit/test-cli-init.js && node tests/unit/test-cli-web-help.js && node tests/unit/test-web-static-assets.js && node tests/unit/test-fs-utils.js && node tests/unit/test-search-utils.js && node tests/unit/test-index-utils.js && node tests/unit/test-task-schema.js && node tests/unit/test-daily-generation.js && node tests/unit/test-report-generation.js && node tests/unit/test-oracle-retrieval.js && node tests/unit/test-task-completion.js && node tests/unit/test-migrate-data.js && node tests/unit/test-blockers-validation.js && node tests/unit/test-blockers-report.js && node tests/unit/test-sm-weekly-report.js && node tests/integration/test-ingestor-task.js"
|
|
15
17
|
},
|
|
16
18
|
"keywords": [],
|
|
17
19
|
"author": "",
|