@anmol-srv/sigil 0.18.2 → 0.18.3

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anmol-srv/sigil",
3
- "version": "0.18.2",
3
+ "version": "0.18.3",
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": {
@@ -28,4 +28,25 @@ EXISTING: "Session started 2 minutes late"
28
28
  NEW: "Session started on time"
29
29
  → **CONTRADICT**
30
30
 
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
+
31
52
  Respond with exactly one of: UPDATE, ADD, or CONTRADICT.
@@ -22,7 +22,8 @@ import { buildUrlConnection, classifyProvider } from './url.js';
22
22
  import { ClientPGlite, PGLITE_DB_PATH } from '../pglite-adapter.js';
23
23
 
24
24
  export function selectDriver(config) {
25
- if (config.db.mode === 'embedded') {
25
+ const mode = config.db.mode;
26
+ if (mode === 'embedded') {
26
27
  return {
27
28
  kind: 'embedded',
28
29
  provider: 'pglite',
@@ -39,12 +40,45 @@ export function selectDriver(config) {
39
40
  client: 'pg',
40
41
  };
41
42
  }
42
- return {
43
- kind: 'local',
44
- provider: 'local',
45
- connection: normalizeConnection(buildLocalConnection(config)),
46
- client: 'pg',
47
- };
43
+ // Field-based local Postgres — ONLY when the user EXPLICITLY chose it: setup
44
+ // persisted mode 'local', or legacy SIGIL_DB_* env vars are present. A null/
45
+ // unknown mode with no URL and no env means setup never finished — and
46
+ // building a local driver here would silently point config.db's defaults
47
+ // (localhost:5432, user sigil_app) at whatever foreign Postgres owns that
48
+ // port, producing a baffling auth error against someone else's database
49
+ // instead of an honest "Sigil isn't set up". Fail loud instead.
50
+ if (mode === 'local' || hasExplicitLocalEnv()) {
51
+ return {
52
+ kind: 'local',
53
+ provider: 'local',
54
+ connection: normalizeConnection(buildLocalConnection(config)),
55
+ client: 'pg',
56
+ };
57
+ }
58
+ throw notConfiguredError();
59
+ }
60
+
61
+ // Legacy/dev escape hatch: discrete connection env vars select the local driver
62
+ // even without a persisted mode (the original Sigil behavior). SIGIL_DB_MODE is
63
+ // already folded into config.db.mode, so it's covered by the mode check above.
64
+ function hasExplicitLocalEnv() {
65
+ return Boolean(
66
+ process.env.SIGIL_DB_HOST
67
+ || process.env.SIGIL_DB_PORT
68
+ || process.env.SIGIL_DB_NAME
69
+ || process.env.SIGIL_DB_USER
70
+ || process.env.SIGIL_DB_PASSWORD,
71
+ );
72
+ }
73
+
74
+ function notConfiguredError() {
75
+ const err = new Error(
76
+ 'Sigil has no database configured yet. Run `sigil quickstart` (zero-prerequisite '
77
+ + 'embedded engine) or complete setup in the GUI. Refusing to connect to a default '
78
+ + 'localhost:5432 — that would hit whatever Postgres happens to own that port, not Sigil\'s.',
79
+ );
80
+ err.code = 'not_configured';
81
+ return err;
48
82
  }
49
83
 
50
84
  // pg throws "SASL: client password must be a string" if password is null/