@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
package/install.sh
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Sigil installer. Every way in lands on the same single install at ~/.sigil/app:
|
|
3
|
+
#
|
|
4
|
+
# curl -fsSL https://raw.githubusercontent.com/Anmol-Srv/sigil/master/install.sh | sh
|
|
5
|
+
# npm i -g @anmol-srv/sigil (the npm `sigil` runs THIS script, bundled)
|
|
6
|
+
# npx @anmol-srv/sigil (same)
|
|
7
|
+
#
|
|
8
|
+
# One owner matters: the daemon + embedded DB are single-process, and two copies
|
|
9
|
+
# of Sigil fighting over ~/.sigil/db corrupt it. So npm never runs Sigil from its
|
|
10
|
+
# own directory (see src/lib/npm-door.js). This script clones the `release`
|
|
11
|
+
# branch into ~/.sigil/app, installs its runtime deps, and `sigil update` later
|
|
12
|
+
# fast-forwards that clone. CI publishes the same version to npm and the release
|
|
13
|
+
# branch on every release, so both channels always carry the latest Sigil.
|
|
14
|
+
#
|
|
15
|
+
# Environment overrides (mostly for testing):
|
|
16
|
+
# SIGIL_BRANCH=master track another branch SIGIL_REPO=<url|path> clone from elsewhere
|
|
17
|
+
# SIGIL_NO_LAUNCH=1 install only, no setup SIGIL_SKIP_TMUX=1 skip the optional tmux step
|
|
18
|
+
#
|
|
19
|
+
# Division of labour (deliberate — see init.js: "the terminal wizard and the
|
|
20
|
+
# browser wizard can never diverge"):
|
|
21
|
+
# • THIS script detects only INSTALL-relevant host facts (OS, node, git) and
|
|
22
|
+
# installs persistently: clone → deps → PATH.
|
|
23
|
+
# • `sigil init` (Node, run at the end) does the rich DB + connector detection
|
|
24
|
+
# and writes the launcher shims. We do NOT reimplement that here.
|
|
25
|
+
#
|
|
26
|
+
# POSIX sh only (this is piped to `sh`). No bashisms.
|
|
27
|
+
|
|
28
|
+
set -e
|
|
29
|
+
|
|
30
|
+
REPO="${SIGIL_REPO:-https://github.com/Anmol-Srv/sigil.git}"
|
|
31
|
+
BRANCH="${SIGIL_BRANCH:-release}" # override: SIGIL_BRANCH=master curl ... | sh
|
|
32
|
+
SIGIL_HOME="${SIGIL_HOME:-$HOME/.sigil}"
|
|
33
|
+
APP_DIR="$SIGIL_HOME/app"
|
|
34
|
+
BIN_DIR="$HOME/.sigil/bin"
|
|
35
|
+
MIN_NODE_MAJOR=20
|
|
36
|
+
|
|
37
|
+
# ── output helpers ────────────────────────────────────────────────────────────
|
|
38
|
+
if [ -t 1 ]; then
|
|
39
|
+
B="$(printf '\033[1m')"; DIM="$(printf '\033[2m')"; R="$(printf '\033[0m')"
|
|
40
|
+
GREEN="$(printf '\033[32m')"; RED="$(printf '\033[31m')"; YEL="$(printf '\033[33m')"
|
|
41
|
+
else
|
|
42
|
+
B=''; DIM=''; R=''; GREEN=''; RED=''; YEL=''
|
|
43
|
+
fi
|
|
44
|
+
say() { printf '%s\n' "$*"; }
|
|
45
|
+
step() { printf '%s→%s %s\n' "$GREEN" "$R" "$*"; }
|
|
46
|
+
warn() { printf '%s!%s %s\n' "$YEL" "$R" "$*" >&2; }
|
|
47
|
+
die() { printf '%s✗ %s%s\n' "$RED" "$*" "$R" >&2; exit 1; }
|
|
48
|
+
have() { command -v "$1" >/dev/null 2>&1; }
|
|
49
|
+
|
|
50
|
+
printf '%s\n' "${B}Sigil${R} — persistent memory for your AI agents"
|
|
51
|
+
say "${DIM}Installing from git (${BRANCH})…${R}"
|
|
52
|
+
say ""
|
|
53
|
+
|
|
54
|
+
# ── 1. host detection (install-relevant ONLY) ─────────────────────────────────
|
|
55
|
+
OS="$(uname -s 2>/dev/null || echo unknown)"
|
|
56
|
+
case "$OS" in
|
|
57
|
+
Darwin|Linux) ;; # Linux covers WSL (uname reports Linux inside WSL).
|
|
58
|
+
MINGW*|MSYS*|CYGWIN*)
|
|
59
|
+
warn "This looks like native Windows ($OS)."
|
|
60
|
+
die "Sigil is unsupported on native Windows. Install it inside WSL (Windows Subsystem for Linux):
|
|
61
|
+
https://learn.microsoft.com/windows/wsl/install" ;;
|
|
62
|
+
*) warn "Unsupported/unknown OS '$OS'."
|
|
63
|
+
die "Stopping — Sigil targets macOS, Linux, and Windows via WSL." ;;
|
|
64
|
+
esac
|
|
65
|
+
|
|
66
|
+
have git || die "Sigil installs from git but \`git\` was not found.
|
|
67
|
+
Install git (https://git-scm.com or your package manager), then re-run this installer."
|
|
68
|
+
|
|
69
|
+
have node || die "Sigil needs Node.js $MIN_NODE_MAJOR+ but \`node\` was not found.
|
|
70
|
+
Install it (https://nodejs.org or \`nvm install $MIN_NODE_MAJOR\`), then re-run this installer."
|
|
71
|
+
|
|
72
|
+
NODE_MAJOR="$(node -p 'process.versions.node.split(".")[0]' 2>/dev/null || echo 0)"
|
|
73
|
+
if [ "$NODE_MAJOR" -lt "$MIN_NODE_MAJOR" ] 2>/dev/null; then
|
|
74
|
+
die "Sigil needs Node.js $MIN_NODE_MAJOR+, but you have $(node -v 2>/dev/null).
|
|
75
|
+
Upgrade Node (e.g. \`nvm install $MIN_NODE_MAJOR\`), then re-run this installer."
|
|
76
|
+
fi
|
|
77
|
+
|
|
78
|
+
have npm || die "Sigil needs \`npm\` to install its runtime dependencies (it ships with Node).
|
|
79
|
+
Install Node from https://nodejs.org (npm is bundled), then re-run this installer."
|
|
80
|
+
|
|
81
|
+
step "Node $(node -v) + git detected."
|
|
82
|
+
|
|
83
|
+
# ── 2. clone (or update) the release branch ───────────────────────────────────
|
|
84
|
+
# Idempotent: a re-run of the installer acts as an update. We fetch + hard-reset
|
|
85
|
+
# rather than merge — the release branch is a derived, force-pushed artifact
|
|
86
|
+
# (CI commits the built dist/), so a 3-way merge would spuriously conflict.
|
|
87
|
+
mkdir -p "$SIGIL_HOME"
|
|
88
|
+
if [ -d "$APP_DIR/.git" ]; then
|
|
89
|
+
step "Updating existing install at $APP_DIR…"
|
|
90
|
+
git -C "$APP_DIR" fetch --depth 1 --quiet origin "$BRANCH" \
|
|
91
|
+
|| die "Could not fetch '$BRANCH' from $REPO — check your network."
|
|
92
|
+
git -C "$APP_DIR" reset --hard --quiet FETCH_HEAD
|
|
93
|
+
else
|
|
94
|
+
# A non-git dir here is a leftover from a different install method — replace it.
|
|
95
|
+
[ -e "$APP_DIR" ] && { warn "Replacing non-git directory at $APP_DIR"; rm -rf "$APP_DIR"; }
|
|
96
|
+
step "Cloning Sigil into $APP_DIR…"
|
|
97
|
+
git clone --depth 1 --branch "$BRANCH" --quiet "$REPO" "$APP_DIR" \
|
|
98
|
+
|| die "Clone failed — is '$BRANCH' a valid branch of $REPO, and is the network up?"
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
# ── 3. install runtime dependencies ───────────────────────────────────────────
|
|
102
|
+
# dist/ is already committed on the release branch (CI builds it), so there is no
|
|
103
|
+
# build step — we only need the runtime deps (the bundle keeps native/WASM/large
|
|
104
|
+
# packages external). --omit=dev skips everything bundled into dist/ at build time.
|
|
105
|
+
step "Installing runtime dependencies…"
|
|
106
|
+
( cd "$APP_DIR" && npm install --omit=dev --no-audit --no-fund --loglevel=error ) \
|
|
107
|
+
|| die "\`npm install\` failed in $APP_DIR. Re-run the installer, or cd there and inspect."
|
|
108
|
+
|
|
109
|
+
# ── 3b. evict a LEGACY global npm install ─────────────────────────────────────
|
|
110
|
+
# npm releases before 0.22 were full installs that ran their own daemon + PGlite
|
|
111
|
+
# version; two installs fighting over the single-process embedded DB
|
|
112
|
+
# (~/.sigil/db) is what corrupts it ("Aborted()"). Remove those. Newer npm
|
|
113
|
+
# releases only hand off to ~/.sigil/app, so they stay. Best-effort, never fatal.
|
|
114
|
+
NPM_GLOBAL_ROOT="$(npm root -g 2>/dev/null || echo '')"
|
|
115
|
+
NPM_GLOBAL_PKG="$NPM_GLOBAL_ROOT/@anmol-srv/sigil"
|
|
116
|
+
if [ -n "$NPM_GLOBAL_ROOT" ] && [ -d "$NPM_GLOBAL_PKG" ]; then
|
|
117
|
+
if ! node -e 'const v=require(process.argv[1]).version.split(".").map(Number);process.exit(v[0]>0||v[1]>=22?0:1)' "$NPM_GLOBAL_PKG/package.json" 2>/dev/null; then
|
|
118
|
+
step "Removing an old global npm install of Sigil (it ran its own copy)…"
|
|
119
|
+
npm rm -g @anmol-srv/sigil >/dev/null 2>&1 \
|
|
120
|
+
|| warn "Could not remove the old global npm install — remove it with: npm rm -g @anmol-srv/sigil"
|
|
121
|
+
fi
|
|
122
|
+
fi
|
|
123
|
+
|
|
124
|
+
# ── 4. install launchers and put them on PATH ─────────────────────────────────
|
|
125
|
+
# Launchers must work before setup, including on headless installs and when the
|
|
126
|
+
# user chooses to connect no agents. Reuse the same renderer as sigil connect.
|
|
127
|
+
CLI="$APP_DIR/dist/cli.js"
|
|
128
|
+
[ -f "$CLI" ] || die "Install looks incomplete — $CLI is missing. Re-run the installer."
|
|
129
|
+
(
|
|
130
|
+
cd "$APP_DIR" || exit 1
|
|
131
|
+
node --input-type=module - <<'NODE'
|
|
132
|
+
import { writeLauncherShim } from './src/lib/clients/shim.js';
|
|
133
|
+
await writeLauncherShim();
|
|
134
|
+
NODE
|
|
135
|
+
) || die 'Could not install Sigil launchers. Re-run the installer.'
|
|
136
|
+
|
|
137
|
+
ensure_path() {
|
|
138
|
+
rc="$1"
|
|
139
|
+
marker="# added by sigil installer"
|
|
140
|
+
if grep -qF "$marker" "$rc" 2>/dev/null; then return 0; fi
|
|
141
|
+
{
|
|
142
|
+
printf '\n%s\n' "$marker"
|
|
143
|
+
printf '%s\n' 'export PATH="$HOME/.sigil/bin:$PATH"'
|
|
144
|
+
} >> "$rc" || die "Could not add Sigil to PATH in $rc."
|
|
145
|
+
step "Added ~/.sigil/bin to PATH in $rc"
|
|
146
|
+
}
|
|
147
|
+
# Create the active shell's rc file if missing. For bash login shells, use the
|
|
148
|
+
# first profile bash reads so an existing login configuration keeps running.
|
|
149
|
+
case "${SHELL:-}" in
|
|
150
|
+
*zsh) ensure_path "${ZDOTDIR:-$HOME}/.zshrc" ;;
|
|
151
|
+
*bash)
|
|
152
|
+
ensure_path "$HOME/.bashrc"
|
|
153
|
+
if [ -f "$HOME/.bash_profile" ]; then ensure_path "$HOME/.bash_profile"
|
|
154
|
+
elif [ -f "$HOME/.bash_login" ]; then ensure_path "$HOME/.bash_login"
|
|
155
|
+
else ensure_path "$HOME/.profile"
|
|
156
|
+
fi ;;
|
|
157
|
+
*) ensure_path "$HOME/.profile" ;;
|
|
158
|
+
esac
|
|
159
|
+
PATH="$BIN_DIR:$PATH"; export PATH
|
|
160
|
+
|
|
161
|
+
# ── 4b. optional: tmux for the managed-session engine ─────────────────────────
|
|
162
|
+
# Sigil's managed-session engine (SIGIL_MANAGED_SESSION=true) keeps a warm
|
|
163
|
+
# `claude`/`codex` worker alive inside tmux to avoid re-paying agentic cold-start
|
|
164
|
+
# per LLM call. tmux is OPTIONAL: without it the engine silently uses the
|
|
165
|
+
# one-shot path. Best-effort install on macOS/Linux; never fatal.
|
|
166
|
+
ensure_tmux() {
|
|
167
|
+
[ "${SIGIL_SKIP_TMUX:-}" = "1" ] && return 0
|
|
168
|
+
have tmux && return 0
|
|
169
|
+
say "Installing tmux (optional — powers the warm managed-session engine)..."
|
|
170
|
+
case "$OS" in
|
|
171
|
+
Darwin) have brew && brew install tmux >/dev/null 2>&1 ;;
|
|
172
|
+
Linux)
|
|
173
|
+
if have apt-get; then sudo apt-get install -y tmux >/dev/null 2>&1
|
|
174
|
+
elif have dnf; then sudo dnf install -y tmux >/dev/null 2>&1
|
|
175
|
+
elif have yum; then sudo yum install -y tmux >/dev/null 2>&1
|
|
176
|
+
elif have pacman; then sudo pacman -S --noconfirm tmux >/dev/null 2>&1
|
|
177
|
+
elif have apk; then sudo apk add tmux >/dev/null 2>&1
|
|
178
|
+
fi ;;
|
|
179
|
+
esac
|
|
180
|
+
if have tmux; then
|
|
181
|
+
step "tmux ready: $(command -v tmux)"
|
|
182
|
+
else
|
|
183
|
+
warn "tmux not installed — the managed-session engine will use the one-shot path."
|
|
184
|
+
warn "To enable it later: install tmux, then set SIGIL_MANAGED_SESSION=true."
|
|
185
|
+
fi
|
|
186
|
+
}
|
|
187
|
+
ensure_tmux
|
|
188
|
+
|
|
189
|
+
VERSION="$(node -p 'require(process.argv[1]).version' "$APP_DIR/package.json" 2>/dev/null || echo '')"
|
|
190
|
+
step "Sigil ${VERSION} installed at $APP_DIR"
|
|
191
|
+
|
|
192
|
+
# The npm entry point runs this script, then launches Sigil itself.
|
|
193
|
+
[ "${SIGIL_NO_LAUNCH:-}" = "1" ] && exit 0
|
|
194
|
+
|
|
195
|
+
# ── 5. hand off to the SHARED Node first-run flow ─────────────────────────────
|
|
196
|
+
# Piped installs (curl … | sh) have the script on stdin, not the terminal — so
|
|
197
|
+
# reconnect to the controlling TTY. Test opening it: the device file can be
|
|
198
|
+
# readable in a headless shell even when this process has no controlling TTY.
|
|
199
|
+
if (exec 3</dev/tty) 2>/dev/null; then
|
|
200
|
+
say ""
|
|
201
|
+
say "${B}Starting Sigil${R} — it will detect your database and AI clients next."
|
|
202
|
+
say ""
|
|
203
|
+
exec "$BIN_DIR/sigil" < /dev/tty
|
|
204
|
+
else
|
|
205
|
+
say "Sigil installed. To configure it from an interactive terminal, run:"
|
|
206
|
+
say " ${B}\"$BIN_DIR/sigil\" init${R}"
|
|
207
|
+
fi
|
|
@@ -1,41 +1,47 @@
|
|
|
1
1
|
# Hermes integration
|
|
2
2
|
|
|
3
|
-
Sigil ships as a [Hermes Agent](https://hermes.chat) memory provider plugin.
|
|
3
|
+
Sigil ships as a [Hermes Agent](https://hermes.chat) memory provider plugin. Unlike the MCP clients (Claude Code, Cursor, Codex CLI, Kiro), Hermes has a first-class Python memory-provider plugin system, so integration means dropping a package into Hermes' plugin tree and setting one config key.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
|
|
9
|
-
scp -r integrations/hermes/plugin/ \
|
|
10
|
-
claude@neutron:.hermes/hermes-agent/plugins/memory/sigil/
|
|
11
|
-
|
|
12
|
-
# 2. On the server:
|
|
13
|
-
ssh claude@neutron
|
|
14
|
-
sigil --help # confirm sigil CLI is on PATH
|
|
15
|
-
sigil init # configure DB + embedder + LLM (once)
|
|
16
|
-
hermes config set memory.provider sigil
|
|
8
|
+
sigil connect --clients hermes
|
|
17
9
|
```
|
|
18
10
|
|
|
19
|
-
|
|
11
|
+
That copies [`plugin/`](./plugin) into `$HERMES_HOME/plugins/sigil/` and sets `memory.provider: sigil` in **every** profile's `config.yaml` — the top-level `~/.hermes/config.yaml` plus each `~/.hermes/profiles/*/config.yaml`. Restart Hermes afterwards.
|
|
12
|
+
|
|
13
|
+
On a remote host, run `sigil init` there first (the plugin needs a working local DB + embedder), then `sigil connect --clients hermes`.
|
|
14
|
+
|
|
15
|
+
## One pod per profile
|
|
16
|
+
|
|
17
|
+
Hermes runs several independent agents out of one install — `igris`, `xero`, `iron` — each with its own `$HERMES_HOME`. Sigil gives **each profile its own pod**, derived from the `hermes_home` kwarg Hermes passes to `initialize()`:
|
|
18
|
+
|
|
19
|
+
```
|
|
20
|
+
~/.hermes/profiles/xero → pod hermes:xero
|
|
21
|
+
~/.hermes → pod hermes:<active_profile>
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
This is Hermes' own requirement, not a Sigil preference — its plugin contract states that storage paths *must* be scoped by `hermes_home`. Keying on the platform (cli/telegram/imessage) instead would have two profiles chatting on the same platform writing into one another's space.
|
|
25
|
+
|
|
26
|
+
**Isolation here means ownership, not a wall.** Every profile writes to the `default` namespace and reads it unscoped, so `xero` can recall what `igris` learned, and both see what Claude Code wrote. The pod records *who* learned a fact; it does not gate who may know it.
|
|
20
27
|
|
|
21
28
|
## What the plugin does
|
|
22
29
|
|
|
23
30
|
| Hermes hook | Sigil call | Why |
|
|
24
31
|
|---|---|---|
|
|
25
|
-
| `is_available()` | `which
|
|
26
|
-
| `initialize(session_id, platform,
|
|
27
|
-
| `prefetch(query)` | `sigil search <q> --namespace=
|
|
28
|
-
| `sync_turn(user, assistant)` | `sigil
|
|
29
|
-
| `get_tool_schemas()` | `sigil_search`, `sigil_remember` | Lets the model
|
|
30
|
-
|
|
31
|
-
The contract Hermes expects is documented at `~/.hermes/hermes-agent/website/docs/developer-guide/memory-provider-plugin.md` on any Hermes install.
|
|
32
|
+
| `is_available()` | `shutil.which("sigil")` | No network call — just check the binary is on PATH. |
|
|
33
|
+
| `initialize(session_id, platform, hermes_home)` | — | Captures `hermes_home`; the profile is derived from it CLI-side. |
|
|
34
|
+
| `prefetch(query)` | `sigil search <q> --namespace=default --limit=5 --no-graph --no-route --no-synthesize` | Unscoped read of the shared brain. |
|
|
35
|
+
| `sync_turn(user, assistant)` | `sigil ingest-turn --user <text> --hermes-home <path>` in a daemon thread | Daemon **classifies and extracts facts**, then attaches them to the profile pod — the same path Claude Code's Stop hook uses. |
|
|
36
|
+
| `get_tool_schemas()` | `sigil_search`, `sigil_remember` | Lets the model drill down or save one explicit fact mid-turn. |
|
|
32
37
|
|
|
33
|
-
|
|
38
|
+
`sync_turn` uses `ingest-turn`, not `remember`. `remember` is the **atomic lane**: it stores a string verbatim with no extraction and rejects anything document-shaped. A whole conversational turn is not a fact, and routing turns through `remember` meant any turn containing a markdown list was rejected and silently dropped. The explicit `sigil_remember` *tool* still uses `remember`, which is correct — there the model really is handing over one short fact.
|
|
34
39
|
|
|
35
|
-
|
|
40
|
+
The contract Hermes expects is documented at `$HERMES_HOME/hermes-agent/website/docs/developer-guide/memory-provider-plugin.md` on any Hermes install.
|
|
36
41
|
|
|
37
42
|
## Caveats
|
|
38
43
|
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
- **The plugin shells out
|
|
44
|
+
- **`sigil` must be on `PATH`** for whatever user runs Hermes. If `which sigil` returns nothing, `is_available()` returns false and Hermes silently falls back to its built-in memory — no error, just no Sigil. Systemd units often have a minimal `PATH` that excludes `~/.sigil/bin`; check that first when memory seems inert on a server.
|
|
45
|
+
- **Run `sigil init` on the Hermes host** before activating the plugin.
|
|
46
|
+
- **The plugin shells out per turn.** Prefetch latency is `sigil search` latency (~0.4s locally). If Hermes' per-turn budget is tighter, an in-process Python↔Node bridge is the next step — out of scope for now.
|
|
47
|
+
- **Install location matters.** The plugin goes in `$HERMES_HOME/plugins/`, the supported third-party location. Hermes' bundled `hermes-agent/plugins/memory/` tree is documented as closed to new providers and can be overwritten by a Hermes upgrade; `sigil connect` removes any stale copy it finds there.
|
|
@@ -10,7 +10,7 @@ This plugin makes that real: every Hermes turn lands in a Sigil namespace, every
|
|
|
10
10
|
|
|
11
11
|
## Requirements
|
|
12
12
|
|
|
13
|
-
- Sigil CLI on `PATH
|
|
13
|
+
- Sigil CLI on `PATH` — install with `curl -fsSL https://raw.githubusercontent.com/Anmol-Srv/sigil/master/install.sh | sh` (or `npm install -g @anmol-srv/sigil`; avoid `npx`/`pnpx`, which run from a throwaway cache)
|
|
14
14
|
- `sigil init` completed once (configures DB, embedder, LLM provider)
|
|
15
15
|
- Postgres reachable from this machine (local install or shared via Tailscale / cloud)
|
|
16
16
|
|
|
@@ -100,8 +100,8 @@ class SigilProvider(MemoryProvider):
|
|
|
100
100
|
def __init__(self) -> None:
|
|
101
101
|
self._session_id: str = ""
|
|
102
102
|
self._platform: str = "cli"
|
|
103
|
-
self._namespace: str = "
|
|
104
|
-
self._search_namespaces: str = "
|
|
103
|
+
self._namespace: str = "default"
|
|
104
|
+
self._search_namespaces: str = "default"
|
|
105
105
|
self._hermes_home: str = ""
|
|
106
106
|
self._sync_thread: Optional[threading.Thread] = None
|
|
107
107
|
|
|
@@ -118,14 +118,26 @@ class SigilProvider(MemoryProvider):
|
|
|
118
118
|
def initialize(self, session_id: str, **kwargs: Any) -> None:
|
|
119
119
|
self._session_id = session_id
|
|
120
120
|
self._platform = kwargs.get("platform", "cli")
|
|
121
|
-
|
|
122
|
-
#
|
|
123
|
-
#
|
|
124
|
-
|
|
121
|
+
# Profile isolation, per Hermes' plugin contract: storage MUST be scoped
|
|
122
|
+
# by hermes_home, never by platform. Two profiles chatting on the same
|
|
123
|
+
# platform are different agents and must not share a memory space.
|
|
124
|
+
# Sigil derives the profile name from this path CLI-side, where it is
|
|
125
|
+
# unit-tested; we just forward the kwarg verbatim.
|
|
125
126
|
self._hermes_home = kwargs.get("hermes_home", "")
|
|
127
|
+
# ONE namespace, deliberately.
|
|
128
|
+
#
|
|
129
|
+
# This used to write to `hermes-<platform>` while reading
|
|
130
|
+
# `hermes-<platform>,default`, which had two consequences: the writes
|
|
131
|
+
# never arrived (the namespace was passed as an env var the daemon does
|
|
132
|
+
# not read), and had they arrived, each platform would have been blind
|
|
133
|
+
# to every other one. Isolation is the PROFILE POD's job — it records
|
|
134
|
+
# which agent learned a fact. The namespace is the shared brain, so
|
|
135
|
+
# xero can recall what igris learned and both see Claude Code's memory.
|
|
136
|
+
self._namespace = "default"
|
|
137
|
+
self._search_namespaces = "default"
|
|
126
138
|
logger.info(
|
|
127
|
-
"Sigil provider initialised:
|
|
128
|
-
|
|
139
|
+
"Sigil provider initialised: session=%s platform=%s hermes_home=%s",
|
|
140
|
+
session_id, self._platform, self._hermes_home or "(unset)",
|
|
129
141
|
)
|
|
130
142
|
|
|
131
143
|
def shutdown(self) -> None:
|
|
@@ -192,34 +204,58 @@ class SigilProvider(MemoryProvider):
|
|
|
192
204
|
session_id: str = "") -> None:
|
|
193
205
|
"""Persist memorable content from the just-completed turn.
|
|
194
206
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
207
|
+
Sends the raw turn to `sigil ingest-turn`, which classifies it in the
|
|
208
|
+
daemon and extracts durable facts — the same path Claude Code's Stop
|
|
209
|
+
hook uses.
|
|
198
210
|
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
211
|
+
This used to call `sigil remember`, which was wrong in three ways: it
|
|
212
|
+
is the ATOMIC lane (stores the string verbatim, no extraction), it
|
|
213
|
+
rejects anything document-shaped, so any turn with a markdown list was
|
|
214
|
+
discarded, and its namespace was passed as an env var the daemon never
|
|
215
|
+
reads.
|
|
216
|
+
|
|
217
|
+
Background thread is belt-and-braces so the .run() call can never block
|
|
218
|
+
the agent's turn.
|
|
202
219
|
"""
|
|
203
220
|
text = (user_content or "").strip()
|
|
204
221
|
if not text:
|
|
205
222
|
return
|
|
206
223
|
|
|
207
|
-
#
|
|
208
|
-
# message — its ingestion pipeline classifies, extracts, dedupes.
|
|
209
|
-
# Trimming to a sensible upper bound avoids enormous argv on long
|
|
210
|
-
# pasted content.
|
|
224
|
+
# Trim to a sane upper bound — the classifier wants a turn, not a novel.
|
|
211
225
|
snippet = text[:4000]
|
|
226
|
+
session_id = self._session_id
|
|
227
|
+
hermes_home = self._hermes_home
|
|
228
|
+
platform = self._platform
|
|
212
229
|
|
|
213
230
|
def _save() -> None:
|
|
231
|
+
cmd = [
|
|
232
|
+
"sigil", "ingest-turn",
|
|
233
|
+
"--user", snippet,
|
|
234
|
+
"--platform", platform,
|
|
235
|
+
"--namespace", "default",
|
|
236
|
+
]
|
|
237
|
+
if hermes_home:
|
|
238
|
+
cmd += ["--hermes-home", hermes_home]
|
|
239
|
+
if session_id:
|
|
240
|
+
cmd += ["--session", session_id]
|
|
214
241
|
try:
|
|
215
|
-
subprocess.run(
|
|
216
|
-
|
|
217
|
-
env={**os.environ, "DEFAULT_NAMESPACE": self._namespace},
|
|
242
|
+
result = subprocess.run(
|
|
243
|
+
cmd,
|
|
218
244
|
timeout=_REMEMBER_TIMEOUT_S,
|
|
219
245
|
capture_output=True,
|
|
246
|
+
text=True,
|
|
220
247
|
)
|
|
221
248
|
except Exception as exc: # noqa: BLE001
|
|
222
|
-
logger.warning("sigil
|
|
249
|
+
logger.warning("sigil ingest-turn failed: %s", exc)
|
|
250
|
+
return
|
|
251
|
+
# A non-zero exit is NOT an exception, so the old code swallowed it
|
|
252
|
+
# in silence — which is exactly how every rejected turn went
|
|
253
|
+
# unnoticed. Log it.
|
|
254
|
+
if result.returncode != 0:
|
|
255
|
+
logger.warning(
|
|
256
|
+
"sigil ingest-turn exit %s: %s",
|
|
257
|
+
result.returncode, _clean_text(result.stderr)[:400],
|
|
258
|
+
)
|
|
223
259
|
|
|
224
260
|
# If the previous turn's sync is still running, let it finish first
|
|
225
261
|
# so we don't pile up zombie threads on chatty sessions.
|
|
@@ -314,9 +350,17 @@ class SigilProvider(MemoryProvider):
|
|
|
314
350
|
return _err("fact is required")
|
|
315
351
|
|
|
316
352
|
try:
|
|
353
|
+
# `remember` is right HERE — the model is handing over one short,
|
|
354
|
+
# self-contained fact, which is exactly the atomic lane's contract.
|
|
355
|
+
# (sync_turn uses ingest-turn instead, because a whole turn is not
|
|
356
|
+
# a fact.) --profile scopes it to this agent's pod, resolving or
|
|
357
|
+
# creating it; --namespace is a real flag, unlike the env var that
|
|
358
|
+
# used to be set here and was never read.
|
|
359
|
+
cmd = ["sigil", "remember", fact, "--namespace=default"]
|
|
360
|
+
if self._hermes_home:
|
|
361
|
+
cmd.append(f"--hermes-home={self._hermes_home}")
|
|
317
362
|
result = subprocess.run(
|
|
318
|
-
|
|
319
|
-
env={**os.environ, "DEFAULT_NAMESPACE": self._namespace},
|
|
363
|
+
cmd,
|
|
320
364
|
timeout=_REMEMBER_TIMEOUT_S,
|
|
321
365
|
capture_output=True,
|
|
322
366
|
text=True,
|
package/knexfile.js
CHANGED
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
// Knex config for `npm run migrate` (server-Postgres installs only — embedded/
|
|
2
|
+
// PGlite migrates daemon-side via the migrateSafe RPC, never through knex).
|
|
3
|
+
//
|
|
4
|
+
// config.json is the single source of truth: read the DB connection from it via
|
|
5
|
+
// src/config.js (which owns the database.* → db.* field bridge). No .env, no env
|
|
6
|
+
// vars — `sigil init`/the GUI write config.json, and that's what migrations use.
|
|
7
|
+
import { loadConfig } from './src/setup/config-store.js';
|
|
8
|
+
import config from './src/config.js';
|
|
6
9
|
import { buildLocalConnection } from './src/db/drivers/local-postgres.js';
|
|
7
10
|
import { buildUrlConnection } from './src/db/drivers/url.js';
|
|
8
11
|
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (existsSync(projectEnv)) dotenvConfig({ path: projectEnv, quiet: true });
|
|
14
|
-
if (existsSync(globalEnv) && globalEnv !== projectEnv) dotenvConfig({ path: globalEnv, quiet: true });
|
|
15
|
-
|
|
16
|
-
const env = (key, fallback) => process.env[key] ?? fallback;
|
|
17
|
-
|
|
18
|
-
const url = env('SIGIL_DATABASE_URL', env('DATABASE_URL', ''));
|
|
12
|
+
// Populate the config cache WITHOUT the one-time .env import/rename — merely
|
|
13
|
+
// reading a connection string for `npm run migrate` must not consume the user's
|
|
14
|
+
// ~/.sigil/.env. The daemon/CLI do the real migration on their first load.
|
|
15
|
+
loadConfig({ migrateEnv: false });
|
|
19
16
|
|
|
20
|
-
const connection = url
|
|
21
|
-
? buildUrlConnection(url)
|
|
17
|
+
const connection = config.db.url
|
|
18
|
+
? buildUrlConnection(config.db.url)
|
|
22
19
|
: buildLocalConnection({
|
|
23
20
|
db: {
|
|
24
|
-
host:
|
|
25
|
-
port:
|
|
26
|
-
database:
|
|
27
|
-
user:
|
|
28
|
-
password:
|
|
21
|
+
host: config.db.host,
|
|
22
|
+
port: config.db.port,
|
|
23
|
+
database: config.db.database,
|
|
24
|
+
user: config.db.user,
|
|
25
|
+
password: config.db.password,
|
|
29
26
|
},
|
|
30
27
|
});
|
|
31
28
|
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@anmol-srv/sigil",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.22.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Local-first memory infrastructure for AI coding agents. One brain shared across Claude Code, Codex CLI, Cursor, Kiro, Continue, Cline, Windsurf, or any MCP client. Organized in pluggable pods, stored in your own Postgres. No cloud, no telemetry. Auto-captured from Claude Code via hooks; surfaced everywhere else as a 9-tool MCP server.",
|
|
6
6
|
"bin": {
|
|
7
|
-
"sigil": "dist/
|
|
7
|
+
"sigil": "dist/npm-entry.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"dev": "node --watch src/server.js",
|
|
@@ -12,20 +12,21 @@
|
|
|
12
12
|
"test": "vitest",
|
|
13
13
|
"lint": "eslint src/",
|
|
14
14
|
"lint:fix": "eslint src/ --fix",
|
|
15
|
-
"build": "node build.js",
|
|
16
|
-
"prepublishOnly": "npm run build",
|
|
15
|
+
"build": "node scripts/build-gui.mjs && node build.js",
|
|
17
16
|
"migrate": "knex migrate:latest",
|
|
18
17
|
"migrate:rollback": "knex migrate:rollback",
|
|
19
18
|
"migrate:make": "knex migrate:make",
|
|
20
19
|
"test:reliability": "node test/reliability/run.js",
|
|
21
20
|
"db:test:up": "docker compose up -d db",
|
|
22
|
-
"db:test:down": "docker compose down"
|
|
21
|
+
"db:test:down": "docker compose down",
|
|
22
|
+
"build:gui": "node scripts/build-gui.mjs"
|
|
23
23
|
},
|
|
24
24
|
"engines": {
|
|
25
25
|
"node": ">=20.0.0"
|
|
26
26
|
},
|
|
27
27
|
"files": [
|
|
28
28
|
"dist/",
|
|
29
|
+
"install.sh",
|
|
29
30
|
"prompts/",
|
|
30
31
|
"src/db/migrations/",
|
|
31
32
|
"src/db/drivers/",
|
|
@@ -35,6 +36,9 @@
|
|
|
35
36
|
"LICENSE",
|
|
36
37
|
"README.md"
|
|
37
38
|
],
|
|
39
|
+
"publishConfig": {
|
|
40
|
+
"access": "public"
|
|
41
|
+
},
|
|
38
42
|
"keywords": [
|
|
39
43
|
"sigil",
|
|
40
44
|
"memory",
|
|
@@ -80,28 +84,5 @@
|
|
|
80
84
|
"homepage": "https://github.com/Anmol-Srv/sigil#readme",
|
|
81
85
|
"bugs": {
|
|
82
86
|
"url": "https://github.com/Anmol-Srv/sigil/issues"
|
|
83
|
-
},
|
|
84
|
-
"dependencies": {
|
|
85
|
-
"@iarna/toml": "^2.2.5",
|
|
86
|
-
"@modelcontextprotocol/sdk": "^1.27.1",
|
|
87
|
-
"dotenv": "^17.3.1",
|
|
88
|
-
"knex": "^3.1.0",
|
|
89
|
-
"pg": "^8.20.0",
|
|
90
|
-
"ws": "^8.21.0"
|
|
91
|
-
},
|
|
92
|
-
"optionalDependencies": {
|
|
93
|
-
"@anthropic-ai/sdk": "^0.30.0",
|
|
94
|
-
"@electric-sql/pglite": "^0.4.4",
|
|
95
|
-
"@number0/iroh": "^0.35.0"
|
|
96
|
-
},
|
|
97
|
-
"devDependencies": {
|
|
98
|
-
"@clack/prompts": "^1.2.0",
|
|
99
|
-
"dayjs": "^1.11.19",
|
|
100
|
-
"esbuild": "^0.28.0",
|
|
101
|
-
"eslint": "^10.0.3",
|
|
102
|
-
"lodash-es": "^4.17.23",
|
|
103
|
-
"nanoid": "^5.1.7",
|
|
104
|
-
"vitest": "^4.0.18",
|
|
105
|
-
"zod": "^3.24.0"
|
|
106
87
|
}
|
|
107
88
|
}
|
package/prompts/audm-decision.md
CHANGED
|
@@ -28,4 +28,29 @@ EXISTING: "Session started 2 minutes late"
|
|
|
28
28
|
NEW: "Session started on time"
|
|
29
29
|
→ **CONTRADICT**
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
### State changing over time (same subject + attribute, new value)
|
|
32
|
+
|
|
33
|
+
When both facts describe the **same subject's same attribute or property** but the
|
|
34
|
+
value has changed — a tool was swapped, a role changed, a price moved, a system was
|
|
35
|
+
migrated — the OLD fact is no longer true. Choose UPDATE (the new value replaces the
|
|
36
|
+
old) or CONTRADICT (the old assertion is now false). Do **not** choose ADD just because
|
|
37
|
+
the new fact is phrased as an event ("was migrated", "was promoted", "moved to"): a
|
|
38
|
+
migration/promotion still invalidates the prior state.
|
|
39
|
+
|
|
40
|
+
EXISTING: "The primary datastore is Redis"
|
|
41
|
+
NEW: "The application migrated from Redis to Postgres as the primary datastore"
|
|
42
|
+
→ **CONTRADICT** (same attribute — the primary datastore — old value Redis no longer holds)
|
|
43
|
+
|
|
44
|
+
EXISTING: "All session state is managed within Redis"
|
|
45
|
+
NEW: "Session state management was moved to Postgres LISTEN/NOTIFY"
|
|
46
|
+
→ **UPDATE** (same attribute — where session state lives — changed from Redis to Postgres)
|
|
47
|
+
|
|
48
|
+
EXISTING: "Priya works as a backend engineer on the payments team"
|
|
49
|
+
NEW: "Priya was promoted to engineering manager of the payments team"
|
|
50
|
+
→ **UPDATE** (same subject's role changed; she is no longer a backend engineer)
|
|
51
|
+
|
|
52
|
+
Respond with ONLY a JSON object, no prose and no markdown fences:
|
|
53
|
+
{"decisions":[{"input_index":<integer>,"candidate_key":"<string>","action":"ADD"|"UPDATE"|"CONTRADICT"}]}
|
|
54
|
+
|
|
55
|
+
Return exactly one entry per offered case, echoing that case's input_index and
|
|
56
|
+
candidate_key verbatim. Never omit a case, never merge cases, never add cases.
|