@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.
Files changed (47) hide show
  1. package/README.md +37 -25
  2. package/dist/cli.js +1191 -790
  3. package/dist/daemon.js +664 -302
  4. package/dist/hooks/post-tool-use.js +1 -69
  5. package/dist/hooks/session-end.js +13 -236
  6. package/dist/hooks/stop.js +36 -246
  7. package/dist/hooks/user-prompt-submit.js +25 -288
  8. package/dist/mcp/worker-server.js +6 -0
  9. package/dist/npm-entry.js +10 -0
  10. package/dist/server.js +64 -56
  11. package/install.sh +207 -0
  12. package/integrations/hermes/README.md +30 -24
  13. package/integrations/hermes/plugin/README.md +1 -1
  14. package/integrations/hermes/plugin/__init__.py +68 -24
  15. package/knexfile.js +19 -22
  16. package/package.json +9 -28
  17. package/prompts/audm-decision.md +26 -1
  18. package/prompts/entity-extraction.md +32 -30
  19. package/prompts/graph-extraction.md +20 -2
  20. package/src/db/drivers/index.js +38 -15
  21. package/src/db/migrations/20260629120000_add-trace-event-attribution.cjs +29 -0
  22. package/src/db/migrations/20260629120001_add-llm-log-session-correlation.cjs +29 -0
  23. package/src/db/migrations/20260806120000_add-document-content.cjs +27 -0
  24. package/src/db/migrations/20260806120001_llm-log-model-nullable.cjs +36 -0
  25. package/src/db/migrations/20260811120000_add-relation-provenance.cjs +42 -0
  26. package/src/db/migrations/20260811130000_add-fact-visibility.cjs +67 -0
  27. package/src/db/migrations/20260813090000_rescore-defaulted-vital.cjs +57 -0
  28. package/src/db/migrations/20260814120000_create-ingestion-job.cjs +52 -0
  29. package/src/db/migrations/20260814120100_add-llm-log-queued-ms.cjs +8 -0
  30. package/src/db/migrations/20260814120200_add-active-fact-content-hash-index.cjs +16 -0
  31. package/src/db/migrations/20260814120300_create-relation-candidate-judgment.cjs +25 -0
  32. package/src/gui/web/app.css +851 -84
  33. package/src/gui/web/app.js +796 -383
  34. package/src/gui/web/cmdk.js +238 -0
  35. package/src/gui/web/components.js +64 -0
  36. package/src/gui/web/design/colors_and_type.css +6 -1
  37. package/src/gui/web/graph/GraphIsland.jsx +450 -0
  38. package/src/gui/web/graph/cluster.js +305 -0
  39. package/src/gui/web/graph/cluster.test.js +219 -0
  40. package/src/gui/web/health.js +117 -0
  41. package/src/gui/web/health.test.js +159 -0
  42. package/src/gui/web/icons.js +65 -0
  43. package/src/gui/web/index.html +310 -115
  44. package/src/gui/web/settings.js +386 -0
  45. package/src/gui/web/setup.js +2 -2
  46. package/src/gui/web/toast.js +6 -3
  47. package/src/gui/web/vendor/graph-island.js +52 -0
@@ -0,0 +1,159 @@
1
+ /**
2
+ * The dashboard's two pieces of decision logic, tested without a DOM:
3
+ * which failure gets the banner, and what the Home readout says.
4
+ *
5
+ * The case that matters most is `unavailable` — a store that can't be read
6
+ * must never render as a store that is empty.
7
+ */
8
+ import { describe, it, expect } from 'vitest';
9
+ import { systemAlert, systemCells, condenseProviderError, engineBlocker } from './health.js';
10
+ import { fuzzy } from './cmdk.js';
11
+
12
+ const HEALTHY = {
13
+ db: { healthy: true, error: null, schema: 'ready' },
14
+ writeQueue: 0,
15
+ providers: { llm: { ok: true, provider: 'anthropic', model: 'claude-opus-5' },
16
+ embedding: { ok: true, provider: 'openai', model: 'text-embedding-3-small' } },
17
+ };
18
+ const cell = (status, k) => systemCells(status).find((c) => c.k === k);
19
+
20
+ describe('systemAlert', () => {
21
+ it('stays silent when everything is up', () => {
22
+ expect(systemAlert(HEALTHY)).toBeNull();
23
+ });
24
+
25
+ it('raises an error banner when the store is unreachable, carrying the reason', () => {
26
+ const a = systemAlert({ ...HEALTHY, unavailable: true, db: { healthy: false, error: 'ECONNREFUSED 127.0.0.1:5432' } });
27
+ expect(a.level).toBe('err');
28
+ expect(a.body).toContain('ECONNREFUSED');
29
+ expect(a.action.route).toBe('setup');
30
+ });
31
+
32
+ it('distinguishes a missing schema from an unreachable store', () => {
33
+ const a = systemAlert({ db: { healthy: false, schema: 'missing' } });
34
+ expect(a.title).toMatch(/schema/i);
35
+ expect(a.action.label).toBe('Run migrations');
36
+ });
37
+
38
+ it('prefers the store failure over a simultaneous provider failure', () => {
39
+ const a = systemAlert({ unavailable: true, db: { healthy: false, error: 'down' },
40
+ providers: { embedding: { ok: false, provider: 'openai', error: '401' } } });
41
+ expect(a.title).toMatch(/store/i);
42
+ });
43
+
44
+ it('prefers a dead embedder over a dead LLM', () => {
45
+ const a = systemAlert({ ...HEALTHY, providers: {
46
+ llm: { ok: false, provider: 'anthropic', error: 'timeout' },
47
+ embedding: { ok: false, provider: 'openai', error: '401 bad key' } } });
48
+ expect(a.level).toBe('warn');
49
+ expect(a.body).toContain('401 bad key');
50
+ expect(a.action.label).toBe('Change embedding');
51
+ });
52
+
53
+ it('says nothing while the boot probe has not reported yet', () => {
54
+ expect(systemAlert({ db: { healthy: true }, providers: { llm: null, embedding: null } })).toBeNull();
55
+ });
56
+ });
57
+
58
+ describe('systemCells', () => {
59
+ it('reports an unreadable store as unreachable, never as healthy', () => {
60
+ expect(cell({ unavailable: true, db: { healthy: false } }, 'Store')).toMatchObject({ s: 'err', v: 'unreachable' });
61
+ });
62
+
63
+ it('reports a queued write as a warning with its depth', () => {
64
+ expect(cell({ ...HEALTHY, writeQueue: 3 }, 'Write queue')).toMatchObject({ s: 'warn', v: '3 waiting' });
65
+ });
66
+
67
+ it('leaves an unknown queue depth blank rather than calling it idle', () => {
68
+ expect(cell({ ...HEALTHY, writeQueue: undefined }, 'Write queue')).toMatchObject({ s: '', v: '—' });
69
+ });
70
+
71
+ it('surfaces the provider error as the sub-line when a probe failed', () => {
72
+ const c = cell({ ...HEALTHY, providers: { embedding: { ok: false, provider: 'openai', error: '401' } } }, 'Embedding');
73
+ expect(c).toMatchObject({ s: 'err', v: 'openai failing', sub: '401' });
74
+ });
75
+
76
+ it('condenses a CLI transcript in the sub-line too, not just the banner', () => {
77
+ // One row of a stat strip cannot carry 700 characters of JSON.
78
+ const c = cell({ ...HEALTHY, providers: { llm: { ok: false, provider: 'claude-cli', error: 'claude CLI exited 1: {"is_error":true,"usage":{}}' } } }, 'LLM');
79
+ expect(c.sub).toBe('claude CLI exited 1');
80
+ });
81
+
82
+ it('distinguishes "not configured" from "not probed"', () => {
83
+ expect(cell({ ...HEALTHY, providers: { llm: { ok: false, provider: null, error: 'not configured' } } }, 'LLM').v).toBe('not configured');
84
+ expect(cell({ ...HEALTHY, providers: {} }, 'LLM').v).toBe('not probed');
85
+ });
86
+ });
87
+
88
+ describe('fuzzy', () => {
89
+ it('matches a subsequence, case-insensitively', () => {
90
+ expect(fuzzy('kb', 'Knowledge Base')).toBe(true);
91
+ expect(fuzzy('ACT', 'Activity')).toBe(true);
92
+ expect(fuzzy('dev', 'Devices')).toBe(true);
93
+ });
94
+
95
+ it('rejects characters that are out of order or absent', () => {
96
+ expect(fuzzy('bk', 'Knowledge Base')).toBe(false);
97
+ expect(fuzzy('zz', 'Activity')).toBe(false);
98
+ });
99
+
100
+ it('matches everything on an empty query', () => {
101
+ expect(fuzzy('', 'Anything')).toBe(true);
102
+ });
103
+ });
104
+
105
+ describe('condenseProviderError', () => {
106
+ it('keeps the prose and drops the JSON payload', () => {
107
+ const real = 'claude CLI exited 1: {"is_error":true,"duration_api_ms":0,'
108
+ + '"num_turns":1,"stop_reason":"stop_sequence","session_id":"84613973-4885",'
109
+ + '"usage":{"input_tokens":0,"cache_creation_input_tokens":0}}';
110
+ expect(condenseProviderError(real)).toBe('claude CLI exited 1');
111
+ });
112
+
113
+ it('leaves an ordinary message alone', () => {
114
+ const msg = 'ECONNREFUSED connecting to localhost:11434';
115
+ expect(condenseProviderError(msg)).toBe(msg);
116
+ });
117
+
118
+ it('still says something when the error IS the payload', () => {
119
+ // No prose to keep — showing the raw blob beats showing nothing at all.
120
+ expect(condenseProviderError('{"is_error":true}')).toBe('{"is_error":true}');
121
+ });
122
+
123
+ it('caps a long single-line message', () => {
124
+ const out = condenseProviderError('x'.repeat(400));
125
+ expect(out.length).toBeLessThanOrEqual(160);
126
+ expect(out.endsWith('…')).toBe(true);
127
+ });
128
+
129
+ it('degrades to "unavailable" for empty/missing input', () => {
130
+ expect(condenseProviderError('')).toBe('unavailable');
131
+ expect(condenseProviderError(undefined)).toBe('unavailable');
132
+ expect(condenseProviderError(null)).toBe('unavailable');
133
+ });
134
+
135
+ it('trims the trailing separator left behind by the cut', () => {
136
+ expect(condenseProviderError('failed to start: {"a":1}')).toBe('failed to start');
137
+ });
138
+ });
139
+
140
+ describe('engineBlocker', () => {
141
+ const OK = { tmuxAvailable: true, provider: 'claude-cli' };
142
+
143
+ it('lets the user turn warm workers on when the host can actually run them', () => {
144
+ expect(engineBlocker(OK)).toBeNull();
145
+ });
146
+
147
+ it('refuses without tmux, naming it', () => {
148
+ // The whole engine is warm processes inside tmux; no tmux, no engine.
149
+ expect(engineBlocker({ ...OK, tmuxAvailable: false })).toMatch(/tmux/);
150
+ });
151
+
152
+ it('refuses on an API provider, which has no cold start to amortize', () => {
153
+ expect(engineBlocker({ ...OK, provider: 'openai' })).toMatch(/openai/);
154
+ });
155
+
156
+ it('allows an unset provider rather than blocking on a not-yet-probed daemon', () => {
157
+ expect(engineBlocker({ tmuxAvailable: true, provider: null })).toBeNull();
158
+ });
159
+ });
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Icon set — 16px monoline SVG, `currentColor` stroke, no fills.
3
+ *
4
+ * One geometric family at a single stroke weight, per DESIGN.md's
5
+ * "industrial / utilitarian console" lock: icons are wayfinding, not
6
+ * decoration. They appear in the sidebar, on action buttons, and as group
7
+ * markers in ⌘K — never inside body copy, never as an empty-state illustration.
8
+ *
9
+ * Usage: `icon('search')` returns markup; static markup can instead carry
10
+ * `data-icon="search"` and be hydrated once at boot by `hydrateIcons()`.
11
+ */
12
+
13
+ const PATHS = {
14
+ // ── navigation ──
15
+ home: '<path d="M2 6.4 8 2l6 4.4V14H2z"/><path d="M6 14v-4h4v4"/>',
16
+ layers: '<path d="M8 2 2 5l6 3 6-3-6-3Z"/><path d="M2 8l6 3 6-3"/><path d="M2 11l6 3 6-3"/>',
17
+ graph: '<circle cx="3.8" cy="12.2" r="1.8"/><circle cx="12.2" cy="12.2" r="1.8"/><circle cx="8" cy="3.4" r="1.8"/><path d="M6.6 4.8 4.9 10.5M9.4 4.8l1.7 5.7M5.6 12.2h4.8"/>',
18
+ activity: '<path d="M1.5 8h3l2-5 3 10 2-5h3"/>',
19
+ terminal: '<rect x="1.5" y="2.5" width="13" height="11" rx="1"/><path d="M4.6 6.4 6.9 8.4 4.6 10.4M8.8 10.8h3"/>',
20
+ monitor: '<rect x="1.5" y="2.5" width="13" height="9" rx="1"/><path d="M5.5 14h5M8 11.5V14"/>',
21
+ cpu: '<rect x="4.6" y="4.6" width="6.8" height="6.8" rx="1"/><path d="M6.6 1.6v3M9.4 1.6v3M6.6 11.4v3M9.4 11.4v3M1.6 6.6h3M1.6 9.4h3M11.4 6.6h3M11.4 9.4h3"/>',
22
+ sliders: '<path d="M2 4.6h7M12.6 4.6H14M2 11.4h1.4M7 11.4h7"/><circle cx="10.8" cy="4.6" r="1.7"/><circle cx="5.2" cy="11.4" r="1.7"/>',
23
+ database: '<ellipse cx="8" cy="3.9" rx="5.4" ry="2.3"/><path d="M2.6 3.9v8.2c0 1.27 2.42 2.3 5.4 2.3s5.4-1.03 5.4-2.3V3.9"/><path d="M2.6 8c0 1.27 2.42 2.3 5.4 2.3s5.4-1.03 5.4-2.3"/>',
24
+ doc: '<path d="M9.2 1.6H4.2a.6.6 0 0 0-.6.6v11.6a.6.6 0 0 0 .6.6h7.6a.6.6 0 0 0 .6-.6V5z"/><path d="M9.2 1.6V5h3.2"/>',
25
+
26
+ // ── actions ──
27
+ search: '<circle cx="7.1" cy="7.1" r="4.6"/><path d="m10.5 10.5 3 3"/>',
28
+ refresh: '<path d="M13.4 8a5.4 5.4 0 1 1-1.7-3.9"/><path d="M13.7 2.6v3.2h-3.2"/>',
29
+ plus: '<path d="M8 3v10M3 8h10"/>',
30
+ trash: '<path d="M2.6 4.4h10.8M6 4.4V3a.6.6 0 0 1 .6-.6h2.8a.6.6 0 0 1 .6.6v1.4"/><path d="m4.1 4.4.6 8.6a.6.6 0 0 0 .6.5h5.4a.6.6 0 0 0 .6-.5l.6-8.6"/>',
31
+ copy: '<rect x="5.6" y="5.6" width="8" height="8" rx="1"/><path d="M10.4 5.6V3.4a1 1 0 0 0-1-1H3.4a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.2"/>',
32
+ external: '<path d="M9.5 2.5H13.5V6.5"/><path d="M13.5 2.5 7.6 8.4"/><path d="M12 9.6v3.3a.6.6 0 0 1-.6.6H3.1a.6.6 0 0 1-.6-.6V4.6a.6.6 0 0 1 .6-.6h3.3"/>',
33
+
34
+ // ── state / meaning ──
35
+ zap: '<path d="M9.1 1.6 3.4 9h4.1l-.6 5.4L12.6 7H8.5z"/>',
36
+ alert: '<path d="M8 2.4 14.4 13.6H1.6z"/><path d="M8 6.6v3.1"/><path d="M8 11.9h.01"/>',
37
+ check: '<path d="m3 8.4 3.3 3.3L13 5"/>',
38
+ shield: '<path d="M8 1.8 13.2 4v4.2c0 3-2.2 5-5.2 6-3-1-5.2-3-5.2-6V4z"/><path d="m5.9 8.1 1.5 1.5 2.8-2.8"/>',
39
+ pulse: '<circle cx="8" cy="8" r="2"/><path d="M3.4 3.4a6.5 6.5 0 0 0 0 9.2M12.6 12.6a6.5 6.5 0 0 0 0-9.2"/>',
40
+
41
+ // ── affordances ──
42
+ chevron: '<path d="m6 3.6 4.5 4.4L6 12.4"/>',
43
+ arrow: '<path d="M2.6 8h10.4M9.2 4.2 13 8l-3.8 3.8"/>',
44
+ close: '<path d="m4 4 8 8M12 4l-8 8"/>',
45
+ };
46
+
47
+ export function icon(name, cls = '') {
48
+ const d = PATHS[name];
49
+ if (!d) return '';
50
+ return `<svg class="ic${cls ? ` ${cls}` : ''}" viewBox="0 0 16 16" width="16" height="16" `
51
+ + `fill="none" stroke="currentColor" stroke-width="1.35" stroke-linecap="round" `
52
+ + `stroke-linejoin="round" aria-hidden="true" focusable="false">${d}</svg>`;
53
+ }
54
+
55
+ /**
56
+ * Inject icons into static markup once. Elements opt in with `data-icon="name"`
57
+ * and the SVG is prepended; the flag attribute stops a second pass from
58
+ * double-injecting if this is ever called again.
59
+ */
60
+ export function hydrateIcons(root = document) {
61
+ for (const el of root.querySelectorAll('[data-icon]:not([data-icon-done])')) {
62
+ el.insertAdjacentHTML('afterbegin', icon(el.dataset.icon));
63
+ el.setAttribute('data-icon-done', '');
64
+ }
65
+ }