@anmol-srv/sigil 0.18.2 → 0.22.0
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/README.md +37 -25
- package/dist/cli.js +1191 -790
- package/dist/daemon.js +664 -302
- package/dist/hooks/post-tool-use.js +1 -69
- package/dist/hooks/session-end.js +13 -236
- package/dist/hooks/stop.js +36 -246
- package/dist/hooks/user-prompt-submit.js +25 -288
- package/dist/mcp/worker-server.js +6 -0
- package/dist/npm-entry.js +10 -0
- package/dist/server.js +64 -56
- package/install.sh +207 -0
- package/integrations/hermes/README.md +30 -24
- package/integrations/hermes/plugin/README.md +1 -1
- package/integrations/hermes/plugin/__init__.py +68 -24
- package/knexfile.js +19 -22
- package/package.json +9 -28
- package/prompts/audm-decision.md +26 -1
- package/prompts/entity-extraction.md +32 -30
- package/prompts/graph-extraction.md +20 -2
- package/src/db/drivers/index.js +38 -15
- package/src/db/migrations/20260629120000_add-trace-event-attribution.cjs +29 -0
- package/src/db/migrations/20260629120001_add-llm-log-session-correlation.cjs +29 -0
- package/src/db/migrations/20260806120000_add-document-content.cjs +27 -0
- package/src/db/migrations/20260806120001_llm-log-model-nullable.cjs +36 -0
- package/src/db/migrations/20260811120000_add-relation-provenance.cjs +42 -0
- package/src/db/migrations/20260811130000_add-fact-visibility.cjs +67 -0
- package/src/db/migrations/20260813090000_rescore-defaulted-vital.cjs +57 -0
- package/src/db/migrations/20260814120000_create-ingestion-job.cjs +52 -0
- package/src/db/migrations/20260814120100_add-llm-log-queued-ms.cjs +8 -0
- package/src/db/migrations/20260814120200_add-active-fact-content-hash-index.cjs +16 -0
- package/src/db/migrations/20260814120300_create-relation-candidate-judgment.cjs +25 -0
- package/src/gui/web/app.css +851 -84
- package/src/gui/web/app.js +796 -383
- package/src/gui/web/cmdk.js +238 -0
- package/src/gui/web/components.js +64 -0
- package/src/gui/web/design/colors_and_type.css +6 -1
- package/src/gui/web/graph/GraphIsland.jsx +450 -0
- package/src/gui/web/graph/cluster.js +305 -0
- package/src/gui/web/graph/cluster.test.js +219 -0
- package/src/gui/web/health.js +117 -0
- package/src/gui/web/health.test.js +159 -0
- package/src/gui/web/icons.js +65 -0
- package/src/gui/web/index.html +310 -115
- package/src/gui/web/settings.js +386 -0
- package/src/gui/web/setup.js +2 -2
- package/src/gui/web/toast.js +6 -3
- package/src/gui/web/vendor/graph-island.js +52 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ⌘K — the one bar that does everything. See DESIGN.md › Global ⌘K.
|
|
3
|
+
*
|
|
4
|
+
* Two implicit modes, no tabs:
|
|
5
|
+
* Act — remember a fact, add a device, connect a tool
|
|
6
|
+
* Recall — anything typed also runs a live hybrid memory search
|
|
7
|
+
*
|
|
8
|
+
* Navigation deliberately lives in the sidebar only: it is always visible and
|
|
9
|
+
* one click away, so listing every page here just pushed the recall results —
|
|
10
|
+
* the thing the bar exists for — below the fold.
|
|
11
|
+
*
|
|
12
|
+
* The search half matters most: recall is the product, and until now the
|
|
13
|
+
* dashboard was the only Sigil surface that couldn't run one. Results open the
|
|
14
|
+
* fact in the Knowledge Base with its provenance, so "why did my agent get
|
|
15
|
+
* this?" is two keystrokes from anywhere.
|
|
16
|
+
*
|
|
17
|
+
* Built on native <dialog>: focus trap, backdrop, and Escape come free.
|
|
18
|
+
*/
|
|
19
|
+
import { icon } from './icons.js';
|
|
20
|
+
|
|
21
|
+
const esc = (v) => String(v ?? '').replace(/[&<>"']/g, (c) => (
|
|
22
|
+
{ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]));
|
|
23
|
+
|
|
24
|
+
// Simple subsequence match — "rem" hits "Remember a fact", "dev" hits "Add a device".
|
|
25
|
+
export function fuzzy(needle, hay) {
|
|
26
|
+
const n = needle.toLowerCase(), h = hay.toLowerCase();
|
|
27
|
+
if (!n) return true;
|
|
28
|
+
let i = 0;
|
|
29
|
+
for (const ch of h) if (ch === n[i] && ++i === n.length) return true;
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function initCmdk({ rpc, setRoute, openFact, toast, onRemembered, onIngest }) {
|
|
34
|
+
const dlg = document.getElementById('cmdk');
|
|
35
|
+
const input = document.getElementById('cmdk-input');
|
|
36
|
+
const list = document.getElementById('cmdk-list');
|
|
37
|
+
const foot = document.getElementById('cmdk-mode');
|
|
38
|
+
if (!dlg || !input || !list) return {};
|
|
39
|
+
|
|
40
|
+
let mode = 'command'; // 'command' | 'compose'
|
|
41
|
+
let items = []; // flat, in render order — what ↑/↓/↵ act on
|
|
42
|
+
let cursor = 0;
|
|
43
|
+
let hits = []; // latest memory-search results
|
|
44
|
+
let searchSeq = 0; // guards against out-of-order search responses
|
|
45
|
+
let timer = null;
|
|
46
|
+
|
|
47
|
+
const ACTIONS = [
|
|
48
|
+
{ id: 'remember', label: 'Remember a fact…', icon: 'plus', hint: 'save a short statement to memory',
|
|
49
|
+
run: () => enterCompose() },
|
|
50
|
+
{ id: 'ingest', label: 'Ingest a document…', icon: 'doc', hint: 'store a file whole — spec, notes, transcript',
|
|
51
|
+
run: () => { close(); onIngest?.(); } },
|
|
52
|
+
{ id: 'device', label: 'Add a device', icon: 'monitor', hint: 'create a pairing code',
|
|
53
|
+
run: () => { close(); setRoute('devices'); document.getElementById('dev-new')?.click(); } },
|
|
54
|
+
{ id: 'agents', label: 'Connect a coding tool', icon: 'terminal', hint: 'Claude Code · Codex · Cursor · Kiro',
|
|
55
|
+
run: () => { close(); setRoute('agents'); } },
|
|
56
|
+
{ id: 'llm', label: 'Change LLM provider', icon: 'sliders', hint: 'switch model or key',
|
|
57
|
+
run: () => { close(); setRoute('settings'); document.getElementById('cfg-change-llm')?.click(); } },
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
// ── rendering ──────────────────────────────────────────────────────
|
|
61
|
+
function row(it, i) {
|
|
62
|
+
const on = i === cursor;
|
|
63
|
+
return `<li class="cmdk-row${on ? ' on' : ''}" id="cmdk-o${i}" role="option" aria-selected="${on}" data-i="${i}">
|
|
64
|
+
<span class="cmdk-ic">${icon(it.icon || 'arrow')}</span>
|
|
65
|
+
<span class="cmdk-label">${esc(it.label)}</span>
|
|
66
|
+
${it.hint ? `<span class="cmdk-hint">${esc(it.hint)}</span>` : ''}
|
|
67
|
+
${it.meta ? `<span class="cmdk-meta">${esc(it.meta)}</span>` : ''}
|
|
68
|
+
</li>`;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function render() {
|
|
72
|
+
if (mode === 'compose') {
|
|
73
|
+
list.innerHTML = `<li class="cmdk-note">${icon('zap')}<span>A fact is one short, self-contained statement — it has to make sense on its own. Press <kbd>↵</kbd> to save, <kbd>esc</kbd> to go back.</span></li>`;
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const q = input.value.trim();
|
|
77
|
+
const acts = ACTIONS.filter((a) => fuzzy(q, a.label));
|
|
78
|
+
const mem = hits.map((f) => ({
|
|
79
|
+
label: f.content, icon: 'zap',
|
|
80
|
+
// Provenance over score: "which agent wrote this" is the question the
|
|
81
|
+
// ranker number can't answer, and it's the reason someone opens a fact.
|
|
82
|
+
hint: f.agent || null,
|
|
83
|
+
meta: f.rrfScore != null ? Number(f.rrfScore).toFixed(2) : null,
|
|
84
|
+
run: () => { close(); openFact(f.uid); },
|
|
85
|
+
}));
|
|
86
|
+
|
|
87
|
+
items = [...acts, ...mem];
|
|
88
|
+
if (cursor >= items.length) cursor = Math.max(0, items.length - 1);
|
|
89
|
+
|
|
90
|
+
let html = '';
|
|
91
|
+
let i = 0;
|
|
92
|
+
const group = (title, arr) => {
|
|
93
|
+
if (!arr.length) return;
|
|
94
|
+
html += `<li class="cmdk-group" role="presentation">${esc(title)}</li>`;
|
|
95
|
+
for (const it of arr) html += row(it, i++);
|
|
96
|
+
};
|
|
97
|
+
group('Actions', acts);
|
|
98
|
+
group(q ? `Memory · “${q}”` : 'Memory', mem);
|
|
99
|
+
|
|
100
|
+
if (!items.length) {
|
|
101
|
+
html = q
|
|
102
|
+
? `<li class="cmdk-note">No action or stored fact matches <strong>${esc(q)}</strong>.</li>`
|
|
103
|
+
: `<li class="cmdk-note">Type to search memory, or run a command.</li>`;
|
|
104
|
+
}
|
|
105
|
+
list.innerHTML = html;
|
|
106
|
+
input.setAttribute('aria-activedescendant', items.length ? `cmdk-o${cursor}` : '');
|
|
107
|
+
list.querySelector('.cmdk-row.on')?.scrollIntoView({ block: 'nearest' });
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// ── live recall ────────────────────────────────────────────────────
|
|
111
|
+
// podScope 'global' on purpose: the dashboard has no cwd to scope to, so
|
|
112
|
+
// "search my memory" here has to mean the whole brain, not a guessed project.
|
|
113
|
+
async function runSearch(q) {
|
|
114
|
+
const seq = ++searchSeq;
|
|
115
|
+
if (!q) { hits = []; setFoot(''); render(); return; }
|
|
116
|
+
setFoot('searching…');
|
|
117
|
+
try {
|
|
118
|
+
const res = await rpc('search', { query: q, limit: 6, podScope: 'global' });
|
|
119
|
+
if (seq !== searchSeq) return; // a newer keystroke already won
|
|
120
|
+
hits = res.facts || [];
|
|
121
|
+
setFoot(hits.length ? `${hits.length} fact${hits.length === 1 ? '' : 's'} recalled` : 'no facts matched');
|
|
122
|
+
} catch (err) {
|
|
123
|
+
if (seq !== searchSeq) return;
|
|
124
|
+
hits = [];
|
|
125
|
+
setFoot(err.message || 'search failed');
|
|
126
|
+
}
|
|
127
|
+
render();
|
|
128
|
+
}
|
|
129
|
+
const setFoot = (t) => { if (foot) foot.textContent = t; };
|
|
130
|
+
|
|
131
|
+
// ── compose (remember) ─────────────────────────────────────────────
|
|
132
|
+
function enterCompose() {
|
|
133
|
+
mode = 'compose';
|
|
134
|
+
dlg.classList.add('composing');
|
|
135
|
+
input.value = '';
|
|
136
|
+
input.placeholder = 'A short, self-contained fact…';
|
|
137
|
+
hits = []; setFoot('saves to your memory on this machine');
|
|
138
|
+
render();
|
|
139
|
+
input.focus();
|
|
140
|
+
}
|
|
141
|
+
function exitCompose() {
|
|
142
|
+
mode = 'command';
|
|
143
|
+
dlg.classList.remove('composing');
|
|
144
|
+
input.value = '';
|
|
145
|
+
input.placeholder = 'Search memory or run a command…';
|
|
146
|
+
setFoot('');
|
|
147
|
+
render();
|
|
148
|
+
}
|
|
149
|
+
async function saveFact() {
|
|
150
|
+
const text = input.value.trim();
|
|
151
|
+
if (!text) return;
|
|
152
|
+
|
|
153
|
+
// Close FIRST. `remember` runs the whole ingest pipeline — classification,
|
|
154
|
+
// embedding, AUDM dedup — and on a local claude-cli provider that round
|
|
155
|
+
// trip is routinely a minute or more. Awaiting it before closing left the
|
|
156
|
+
// bar sitting on "saving…" long enough to look hung, over a write that had
|
|
157
|
+
// already been accepted. Your typing is done; the outcome arrives as a
|
|
158
|
+
// toast, which is how every other slow action in the dashboard reports.
|
|
159
|
+
close();
|
|
160
|
+
const dismiss = toast({
|
|
161
|
+
variant: 'info',
|
|
162
|
+
message: 'Saving fact…',
|
|
163
|
+
hint: 'Extraction runs in the background; this can take a moment.',
|
|
164
|
+
timeout: 0,
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
try {
|
|
168
|
+
const r = await rpc('remember', { facts: [text] });
|
|
169
|
+
dismiss();
|
|
170
|
+
const n = r?.added ?? 0;
|
|
171
|
+
toast({
|
|
172
|
+
variant: n ? 'success' : 'info',
|
|
173
|
+
message: n ? 'Fact remembered.' : 'Already known — nothing added.',
|
|
174
|
+
hint: r?.updated ? `${r.updated} existing fact updated.` : undefined,
|
|
175
|
+
});
|
|
176
|
+
onRemembered?.();
|
|
177
|
+
} catch (err) {
|
|
178
|
+
dismiss();
|
|
179
|
+
toast({
|
|
180
|
+
variant: 'error',
|
|
181
|
+
message: `Couldn’t save that fact: ${err.message}`,
|
|
182
|
+
hint: err.hint,
|
|
183
|
+
code: err.code,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
// ── open / close ───────────────────────────────────────────────────
|
|
189
|
+
function open() {
|
|
190
|
+
if (dlg.open) return;
|
|
191
|
+
exitCompose();
|
|
192
|
+
cursor = 0;
|
|
193
|
+
dlg.showModal();
|
|
194
|
+
input.focus();
|
|
195
|
+
}
|
|
196
|
+
function close() { if (dlg.open) dlg.close(); }
|
|
197
|
+
|
|
198
|
+
// ── wiring ─────────────────────────────────────────────────────────
|
|
199
|
+
input.addEventListener('input', () => {
|
|
200
|
+
if (mode === 'compose') return;
|
|
201
|
+
cursor = 0;
|
|
202
|
+
render();
|
|
203
|
+
clearTimeout(timer);
|
|
204
|
+
const q = input.value.trim();
|
|
205
|
+
timer = setTimeout(() => runSearch(q), 220);
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
input.addEventListener('keydown', (e) => {
|
|
209
|
+
if (mode === 'compose') {
|
|
210
|
+
if (e.key === 'Enter') { e.preventDefault(); saveFact(); }
|
|
211
|
+
if (e.key === 'Escape') { e.preventDefault(); e.stopPropagation(); exitCompose(); }
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
if (e.key === 'ArrowDown') { e.preventDefault(); if (items.length) { cursor = (cursor + 1) % items.length; render(); } }
|
|
215
|
+
else if (e.key === 'ArrowUp') { e.preventDefault(); if (items.length) { cursor = (cursor - 1 + items.length) % items.length; render(); } }
|
|
216
|
+
else if (e.key === 'Enter') { e.preventDefault(); items[cursor]?.run(); }
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
list.addEventListener('click', (e) => {
|
|
220
|
+
const r = e.target.closest('.cmdk-row');
|
|
221
|
+
if (r) items[Number(r.dataset.i)]?.run();
|
|
222
|
+
});
|
|
223
|
+
list.addEventListener('mousemove', (e) => {
|
|
224
|
+
const r = e.target.closest('.cmdk-row');
|
|
225
|
+
if (r && Number(r.dataset.i) !== cursor) { cursor = Number(r.dataset.i); render(); }
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
// Click the backdrop (the dialog element itself, outside its panel) to close.
|
|
229
|
+
dlg.addEventListener('click', (e) => { if (e.target === dlg) close(); });
|
|
230
|
+
dlg.addEventListener('close', () => { hits = []; clearTimeout(timer); });
|
|
231
|
+
|
|
232
|
+
document.addEventListener('keydown', (e) => {
|
|
233
|
+
if ((e.metaKey || e.ctrlKey) && e.key.toLowerCase() === 'k') { e.preventDefault(); dlg.open ? close() : open(); }
|
|
234
|
+
});
|
|
235
|
+
document.getElementById('cmdk-trigger')?.addEventListener('click', open);
|
|
236
|
+
|
|
237
|
+
return { open, close, compose: () => { open(); enterCompose(); } };
|
|
238
|
+
}
|
|
@@ -87,4 +87,68 @@ export function setFlowRow(container, id, { phase, detail } = {}) {
|
|
|
87
87
|
if (detail != null) row.querySelector('.step-detail').textContent = detail;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
+
/**
|
|
91
|
+
* One field control, shared by the onboarding wizard and Settings' provider
|
|
92
|
+
* switcher. It exists because they each had their own copy: both rendered
|
|
93
|
+
* `<input type="${f.type}">`, so when the LLM step gained `type: 'select'`
|
|
94
|
+
* model pickers, Settings silently rendered `<input type="select">` — which
|
|
95
|
+
* every browser treats as a plain text box. The result was an empty field where
|
|
96
|
+
* a list of models should be, with no error anywhere.
|
|
97
|
+
*
|
|
98
|
+
* `nameAttr` differs between the two surfaces (data-setup-field vs
|
|
99
|
+
* data-cfg-field), so it's a parameter rather than a second implementation.
|
|
100
|
+
*/
|
|
101
|
+
export function fieldControl(f, nameAttr) {
|
|
102
|
+
const esc = (v) => String(v ?? '').replace(/[&<>"']/g, (c) => (
|
|
103
|
+
{ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]
|
|
104
|
+
));
|
|
105
|
+
const optional = f.optional ? ' data-optional="1"' : '';
|
|
106
|
+
|
|
107
|
+
if (f.type === 'select' && f.options?.length) {
|
|
108
|
+
const chosen = f.default || f.options[0].value;
|
|
109
|
+
const opts = f.options.map((o) => {
|
|
110
|
+
const label = o.label || o.value;
|
|
111
|
+
return `<option value="${esc(o.value)}"${o.value === chosen ? ' selected' : ''}>`
|
|
112
|
+
+ `${esc(label)}${o.hint ? ` — ${esc(o.hint)}` : ''}</option>`;
|
|
113
|
+
}).join('');
|
|
114
|
+
return `<select ${nameAttr}="${esc(f.name)}"${optional}>${opts}</select>`;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return `<input type="${esc(f.type)}" ${nameAttr}="${esc(f.name)}"${optional}`
|
|
118
|
+
+ ` placeholder="${esc(f.placeholder || '')}" autocomplete="off">`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* The app's only "are you sure" — a native <dialog>, so the focus trap,
|
|
123
|
+
* backdrop and Escape-to-cancel come free and the browser's own confirm() (a
|
|
124
|
+
* chrome-coloured box with the origin printed on it) never appears. Cancel is
|
|
125
|
+
* first in DOM order, so it takes the default focus: a destructive action is
|
|
126
|
+
* never one stray Enter away. Resolves false on any dismissal.
|
|
127
|
+
*/
|
|
128
|
+
export function confirmDialog({
|
|
129
|
+
title = 'Are you sure?', message = '',
|
|
130
|
+
confirmLabel = 'Confirm', cancelLabel = 'Cancel', danger = false,
|
|
131
|
+
} = {}) {
|
|
132
|
+
return new Promise((resolve) => {
|
|
133
|
+
const dlg = E('dialog', 'confirm-dlg');
|
|
134
|
+
dlg.innerHTML = `<form method="dialog" class="modal-body">
|
|
135
|
+
<div class="modal-header"><h3></h3></div>
|
|
136
|
+
<div class="modal-content"><p class="confirm-msg"></p></div>
|
|
137
|
+
<div class="modal-footer">
|
|
138
|
+
<button type="submit" class="btn ghost" value=""></button>
|
|
139
|
+
<button type="submit" class="btn" value="ok"></button>
|
|
140
|
+
</div>
|
|
141
|
+
</form>`;
|
|
142
|
+
dlg.querySelector('h3').textContent = title;
|
|
143
|
+
dlg.querySelector('.confirm-msg').textContent = message;
|
|
144
|
+
const [cancelBtn, okBtn] = dlg.querySelectorAll('.modal-footer button');
|
|
145
|
+
cancelBtn.textContent = cancelLabel;
|
|
146
|
+
okBtn.textContent = confirmLabel;
|
|
147
|
+
okBtn.classList.add(danger ? 'danger' : 'primary');
|
|
148
|
+
dlg.addEventListener('close', () => { dlg.remove(); resolve(dlg.returnValue === 'ok'); });
|
|
149
|
+
document.body.append(dlg);
|
|
150
|
+
dlg.showModal();
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
90
154
|
export { E };
|
|
@@ -8,6 +8,11 @@
|
|
|
8
8
|
@import here would block parsing until this file is fully loaded first. */
|
|
9
9
|
|
|
10
10
|
:root {
|
|
11
|
+
/* The dashboard is dark-only by design (DESIGN.md). Without this, natively
|
|
12
|
+
rendered UI — a <select>'s dropdown list, scrollbars, autofill — is drawn
|
|
13
|
+
by the OS in light mode and punches a white hole through the console. */
|
|
14
|
+
color-scheme: dark;
|
|
15
|
+
|
|
11
16
|
/* ========================================================
|
|
12
17
|
COLOR — cool-neutral dark ramp
|
|
13
18
|
Surfaces are layered near-black; text is a desaturated
|
|
@@ -29,7 +34,7 @@
|
|
|
29
34
|
/* Foreground text ramp */
|
|
30
35
|
--fg-1: #f4f5f6; /* primary text, headings, key values */
|
|
31
36
|
--fg-2: #a2a5ab; /* body, secondary text */
|
|
32
|
-
--fg-3: #
|
|
37
|
+
--fg-3: #82858c; /* labels, captions, footer — AA on surfaces (≥4.9:1) */
|
|
33
38
|
--fg-4: #50535a; /* disabled, faint meta */
|
|
34
39
|
|
|
35
40
|
/* ---- Brand (from the Sigil mark gradient) ---- */
|