wisdomgraph 0.3.0__tar.gz → 0.3.2__tar.gz

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 (38) hide show
  1. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/PKG-INFO +8 -9
  2. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/README.md +5 -5
  3. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/pyproject.toml +3 -4
  4. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/tests/test_mcp.py +113 -4
  5. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/__main__.py +10 -4
  6. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/local.py +133 -39
  7. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/mcp.py +38 -6
  8. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdomgraph.egg-info/PKG-INFO +8 -9
  9. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/LICENSE +0 -0
  10. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/setup.cfg +0 -0
  11. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/tests/test_cache.py +0 -0
  12. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/tests/test_classify.py +0 -0
  13. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/tests/test_detect.py +0 -0
  14. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/tests/test_ingest.py +0 -0
  15. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/tests/test_reflect.py +0 -0
  16. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/tests/test_security.py +0 -0
  17. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/tests/test_validate.py +0 -0
  18. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/__init__.py +0 -0
  19. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/cache.py +0 -0
  20. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/classify.py +0 -0
  21. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/connect.py +0 -0
  22. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/detect.py +0 -0
  23. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/docker.py +0 -0
  24. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/export.py +0 -0
  25. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/ingest.py +0 -0
  26. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/merge.py +0 -0
  27. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/reflect.py +0 -0
  28. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/report.py +0 -0
  29. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/security.py +0 -0
  30. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/skill-claw.md +0 -0
  31. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/skill.md +0 -0
  32. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/traverse.py +0 -0
  33. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdom/validate.py +0 -0
  34. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdomgraph.egg-info/SOURCES.txt +0 -0
  35. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdomgraph.egg-info/dependency_links.txt +0 -0
  36. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdomgraph.egg-info/entry_points.txt +0 -0
  37. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdomgraph.egg-info/requires.txt +0 -0
  38. {wisdomgraph-0.3.0 → wisdomgraph-0.3.2}/wisdomgraph.egg-info/top_level.txt +0 -0
@@ -1,8 +1,8 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.2
2
2
  Name: wisdomgraph
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Graph-native persistent cognition for AI agents using Neo4j, DIKW, and MCP
5
- License-Expression: MIT
5
+ License: MIT
6
6
  Project-URL: Homepage, https://github.com/cklam12345/wisdomGraph
7
7
  Project-URL: Repository, https://github.com/cklam12345/wisdomGraph
8
8
  Project-URL: Issues, https://github.com/cklam12345/wisdomGraph/issues
@@ -66,7 +66,6 @@ Requires-Dist: pypdf; extra == "all"
66
66
  Requires-Dist: html2text; extra == "all"
67
67
  Requires-Dist: python-docx; extra == "all"
68
68
  Requires-Dist: openpyxl; extra == "all"
69
- Dynamic: license-file
70
69
 
71
70
  # wisdomGraph
72
71
 
@@ -108,7 +107,7 @@ wisdomGraph does something fundamentally different.
108
107
  | **Memory** | resets each session | accumulates across sessions, projects, months |
109
108
  | **Reasoning** | community detection (topology) | graph path traversal + DIKW hierarchy |
110
109
  | **Feedback loop** | none | Wisdom → Knowledge (neuroplasticity) |
111
- | **Database** | none required | Neo4j Aura (free) or DozerDB Docker |
110
+ | **Database** | none required | Neo4j Aura (free) or local Neo4j Docker |
112
111
 
113
112
  The difference is not incremental. It's architectural. graphify compresses a codebase into a readable report. wisdomGraph builds an artificial epistemology — one that remembers, connects, and grows.
114
113
 
@@ -138,7 +137,7 @@ The feedback loop is critical: when a Wisdom node is queried and found useful, i
138
137
 
139
138
  **Requires:** Python 3.10+ and one of: [Claude Code](https://claude.ai/code), [Codex](https://openai.com/codex), [OpenClaw](https://openclaw.ai), or another MCP host
140
139
 
141
- **And one of:** [Neo4j Aura Free](https://neo4j.com/cloud/platform/aura-graph-database/) (cloud, no install) or [DozerDB](https://dozerdb.org) (local Docker, APOC included)
140
+ **And one of:** [Neo4j Aura Free](https://neo4j.com/cloud/platform/aura-graph-database/) (cloud, no install) or Docker Desktop/Engine for a managed local Neo4j container
142
141
 
143
142
  ```bash
144
143
  pip install 'wisdomgraph[mcp]'
@@ -148,7 +147,7 @@ wisdom quickstart
148
147
  `wisdom quickstart` is the end-to-end first-time setup. It prepares storage, verifies the Neo4j connection, and registers wisdomGraph with detected MCP hosts.
149
148
 
150
149
  ```bash
151
- # Local managed Neo4j/DozerDB backend + detected MCP hosts
150
+ # Local managed Neo4j backend + detected MCP hosts
152
151
  wisdom quickstart
153
152
 
154
153
  # Local backend + Codex only
@@ -170,7 +169,7 @@ wisdom local up
170
169
  wisdom doctor
171
170
  ```
172
171
 
173
- This starts a managed DozerDB/Neo4j container named `wisdomgraph-neo4j`, stores data under `~/.wisdom/neo4j`, generates a local password, saves the connection, and leaves MCP startup cleanly separate.
172
+ This starts a managed `neo4j:latest` container named `wisdomgraph-neo4j`, stores data under `~/.wisdom/neo4j`, uses the documented local login `neo4j/password`, saves the connection, and leaves MCP startup cleanly separate. The implementation uses the Docker CLI directly, so the same `wisdom local up` command works from Windows PowerShell, Windows cmd.exe, macOS Terminal, and Ubuntu Terminal after Docker is installed.
174
173
 
175
174
  Useful commands:
176
175
 
@@ -192,7 +191,7 @@ wisdom connect bolt+s://xxxxxxxx.databases.neo4j.io --user neo4j --password <you
192
191
 
193
192
  Free tier: 200,000 nodes. Enough for years of accumulated wisdom.
194
193
 
195
- ### Option C — Legacy/manual DozerDB Docker (full control, APOC included)
194
+ ### Option C — Optional/manual DozerDB Docker (full control, APOC included)
196
195
 
197
196
  ```bash
198
197
  wisdom docker up # pulls graphstack/dozerdb:5.26.3.0 and starts it
@@ -38,7 +38,7 @@ wisdomGraph does something fundamentally different.
38
38
  | **Memory** | resets each session | accumulates across sessions, projects, months |
39
39
  | **Reasoning** | community detection (topology) | graph path traversal + DIKW hierarchy |
40
40
  | **Feedback loop** | none | Wisdom → Knowledge (neuroplasticity) |
41
- | **Database** | none required | Neo4j Aura (free) or DozerDB Docker |
41
+ | **Database** | none required | Neo4j Aura (free) or local Neo4j Docker |
42
42
 
43
43
  The difference is not incremental. It's architectural. graphify compresses a codebase into a readable report. wisdomGraph builds an artificial epistemology — one that remembers, connects, and grows.
44
44
 
@@ -68,7 +68,7 @@ The feedback loop is critical: when a Wisdom node is queried and found useful, i
68
68
 
69
69
  **Requires:** Python 3.10+ and one of: [Claude Code](https://claude.ai/code), [Codex](https://openai.com/codex), [OpenClaw](https://openclaw.ai), or another MCP host
70
70
 
71
- **And one of:** [Neo4j Aura Free](https://neo4j.com/cloud/platform/aura-graph-database/) (cloud, no install) or [DozerDB](https://dozerdb.org) (local Docker, APOC included)
71
+ **And one of:** [Neo4j Aura Free](https://neo4j.com/cloud/platform/aura-graph-database/) (cloud, no install) or Docker Desktop/Engine for a managed local Neo4j container
72
72
 
73
73
  ```bash
74
74
  pip install 'wisdomgraph[mcp]'
@@ -78,7 +78,7 @@ wisdom quickstart
78
78
  `wisdom quickstart` is the end-to-end first-time setup. It prepares storage, verifies the Neo4j connection, and registers wisdomGraph with detected MCP hosts.
79
79
 
80
80
  ```bash
81
- # Local managed Neo4j/DozerDB backend + detected MCP hosts
81
+ # Local managed Neo4j backend + detected MCP hosts
82
82
  wisdom quickstart
83
83
 
84
84
  # Local backend + Codex only
@@ -100,7 +100,7 @@ wisdom local up
100
100
  wisdom doctor
101
101
  ```
102
102
 
103
- This starts a managed DozerDB/Neo4j container named `wisdomgraph-neo4j`, stores data under `~/.wisdom/neo4j`, generates a local password, saves the connection, and leaves MCP startup cleanly separate.
103
+ This starts a managed `neo4j:latest` container named `wisdomgraph-neo4j`, stores data under `~/.wisdom/neo4j`, uses the documented local login `neo4j/password`, saves the connection, and leaves MCP startup cleanly separate. The implementation uses the Docker CLI directly, so the same `wisdom local up` command works from Windows PowerShell, Windows cmd.exe, macOS Terminal, and Ubuntu Terminal after Docker is installed.
104
104
 
105
105
  Useful commands:
106
106
 
@@ -122,7 +122,7 @@ wisdom connect bolt+s://xxxxxxxx.databases.neo4j.io --user neo4j --password <you
122
122
 
123
123
  Free tier: 200,000 nodes. Enough for years of accumulated wisdom.
124
124
 
125
- ### Option C — Legacy/manual DozerDB Docker (full control, APOC included)
125
+ ### Option C — Optional/manual DozerDB Docker (full control, APOC included)
126
126
 
127
127
  ```bash
128
128
  wisdom docker up # pulls graphstack/dozerdb:5.26.3.0 and starts it
@@ -1,14 +1,13 @@
1
1
  [build-system]
2
- requires = ["setuptools>=68"]
2
+ requires = ["setuptools>=68,<77"]
3
3
  build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "wisdomgraph"
7
- version = "0.3.0"
7
+ version = "0.3.2"
8
8
  description = "Graph-native persistent cognition for AI agents using Neo4j, DIKW, and MCP"
9
9
  readme = "README.md"
10
- license = "MIT"
11
- license-files = ["LICENSE"]
10
+ license = {text = "MIT"}
12
11
  keywords = [
13
12
  "claude", "claude-code", "openclaw", "neo4j", "knowledge-graph",
14
13
  "graphrag", "dikw", "wisdom", "memory", "accumulative", "llm",
@@ -2,6 +2,7 @@
2
2
  from __future__ import annotations
3
3
 
4
4
  import hashlib
5
+ import sys
5
6
  from types import SimpleNamespace
6
7
  from unittest.mock import MagicMock, patch
7
8
 
@@ -665,6 +666,32 @@ def test_mcp_install_rejects_unknown_host():
665
666
 
666
667
  # ── local backend / quickstart CLI ────────────────────────────────────────────
667
668
 
669
+ def test_local_default_image_is_official_neo4j(monkeypatch):
670
+ import wisdom.local as local
671
+
672
+ monkeypatch.delenv("WISDOM_NEO4J_IMAGE", raising=False)
673
+ monkeypatch.delenv("WISDOM_NEO4J_ENGINE", raising=False)
674
+
675
+ assert local._select_image() == "neo4j:latest"
676
+
677
+
678
+ def test_local_dozerdb_engine_is_explicit():
679
+ import wisdom.local as local
680
+
681
+ assert local._select_image(engine="dozerdb") == "graphstack/dozerdb:5.26.3.0"
682
+
683
+
684
+ def test_local_docker_run_args_are_shell_independent(tmp_path, monkeypatch):
685
+ import wisdom.local as local
686
+
687
+ monkeypatch.setattr(local, "BASE_DIR", tmp_path / "neo4j")
688
+ args = local._docker_run_args("neo4j:latest", "password")
689
+
690
+ assert args[:3] == ["docker", "run", "-d"]
691
+ assert "neo4j:latest" == args[-1]
692
+ assert "NEO4J_AUTH=neo4j/password" in args
693
+ assert all(isinstance(part, str) for part in args)
694
+
668
695
  def test_local_up_starts_managed_backend_without_existing_container(tmp_path, monkeypatch):
669
696
  import wisdom.local as local
670
697
 
@@ -685,7 +712,7 @@ def test_local_up_starts_managed_backend_without_existing_container(tmp_path, mo
685
712
 
686
713
  with patch("wisdom.local.shutil.which", return_value="/usr/bin/docker"), \
687
714
  patch("wisdom.local._run", side_effect=fake_run), \
688
- patch("wisdom.local._wait_for_port", return_value=True), \
715
+ patch("wisdom.local._wait_until_ready", return_value=True), \
689
716
  patch("wisdom.local.save_connection") as save:
690
717
  local.up(password="test-password")
691
718
 
@@ -693,7 +720,7 @@ def test_local_up_starts_managed_backend_without_existing_container(tmp_path, mo
693
720
  save.assert_called_once_with(local.URI, local.USER, "test-password")
694
721
 
695
722
 
696
- def test_local_up_reuses_existing_running_backend():
723
+ def test_local_up_reuses_existing_running_backend(tmp_path, monkeypatch):
697
724
  import wisdom.local as local
698
725
 
699
726
  def fake_run(cmd, capture=False):
@@ -703,12 +730,44 @@ def test_local_up_reuses_existing_running_backend():
703
730
  return SimpleNamespace(returncode=0, stdout="abc123\n", stderr="")
704
731
  return SimpleNamespace(returncode=0, stdout="", stderr="")
705
732
 
733
+ pw_path = tmp_path / "local-password"
734
+ pw_path.write_text("stored-secret\n", encoding="utf-8")
735
+ monkeypatch.setattr(local, "PASSWORD_PATH", pw_path)
736
+
706
737
  with patch("wisdom.local.shutil.which", return_value="/usr/bin/docker"), \
707
738
  patch("wisdom.local._run", side_effect=fake_run), \
708
739
  patch("wisdom.local.save_connection") as save:
709
740
  local.up(password="test-password")
710
741
 
711
- save.assert_called_once_with(local.URI, local.USER, "test-password")
742
+ # An existing container keeps its baked-in password; --password is ignored.
743
+ save.assert_called_once_with(local.URI, local.USER, "stored-secret")
744
+
745
+
746
+ def test_wait_until_ready_fails_when_port_never_opens():
747
+ import wisdom.local as local
748
+
749
+ with patch("wisdom.local._wait_for_port", return_value=False), \
750
+ patch("wisdom.local._probe_cypher") as probe:
751
+ assert local._wait_until_ready("password", timeout_s=1) is False
752
+ probe.assert_not_called()
753
+
754
+
755
+ def test_wait_until_ready_waits_for_cypher_after_port_opens():
756
+ import wisdom.local as local
757
+
758
+ # Port is open immediately, but Cypher is only ready on the 2nd probe.
759
+ with patch("wisdom.local._wait_for_port", return_value=True), \
760
+ patch("wisdom.local._probe_cypher", side_effect=[False, True]), \
761
+ patch("wisdom.local.time.sleep"):
762
+ assert local._wait_until_ready("password", timeout_s=5) is True
763
+
764
+
765
+ def test_probe_cypher_is_graceful_without_neo4j_driver(monkeypatch):
766
+ import wisdom.local as local
767
+
768
+ # Simulate the neo4j driver not being importable in this environment.
769
+ monkeypatch.setitem(sys.modules, "neo4j", None)
770
+ assert local._probe_cypher("password") is True
712
771
 
713
772
 
714
773
  def test_quickstart_local_registers_requested_host(monkeypatch):
@@ -722,7 +781,7 @@ def test_quickstart_local_registers_requested_host(monkeypatch):
722
781
  patch("wisdom.__main__._install_mcp") as install_mcp:
723
782
  _run_quickstart()
724
783
 
725
- local_up.assert_called_once_with()
784
+ local_up.assert_called_once_with(password=None, image=None, engine=None)
726
785
  doctor.assert_called_once_with(connect_only=True)
727
786
  install_mcp.assert_called_once_with(host="codex")
728
787
 
@@ -735,3 +794,53 @@ def test_quickstart_existing_requires_uri(monkeypatch):
735
794
 
736
795
  with pytest.raises(SystemExit):
737
796
  _run_quickstart()
797
+
798
+
799
+ # ── MCP driver auto-start ──────────────────────────────────────────────────────
800
+
801
+ def test_get_driver_autostarts_local_backend_on_first_failure():
802
+ import wisdom.mcp as mcp
803
+
804
+ good_driver = object()
805
+ # First get_driver() fails (nothing running); after autostart, it succeeds.
806
+ get_driver = MagicMock(side_effect=[SystemExit(1), good_driver])
807
+
808
+ with patch("wisdom.connect.get_driver", get_driver), \
809
+ patch("wisdom.mcp._try_autostart_local", return_value=True) as autostart:
810
+ assert mcp._get_driver() is good_driver
811
+
812
+ autostart.assert_called_once()
813
+ assert get_driver.call_count == 2
814
+
815
+
816
+ def test_get_driver_raises_helpful_error_when_autostart_unavailable():
817
+ import wisdom.mcp as mcp
818
+
819
+ get_driver = MagicMock(side_effect=SystemExit(1))
820
+
821
+ with patch("wisdom.connect.get_driver", get_driver), \
822
+ patch("wisdom.mcp._try_autostart_local", return_value=False):
823
+ with pytest.raises(RuntimeError) as exc:
824
+ mcp._get_driver()
825
+
826
+ assert "quickstart" in str(exc.value)
827
+ # Only the initial attempt — no retry when autostart could not run.
828
+ assert get_driver.call_count == 1
829
+
830
+
831
+ def test_try_autostart_local_skips_when_docker_absent():
832
+ import wisdom.mcp as mcp
833
+
834
+ with patch("wisdom.local.docker_daemon_available", return_value=False), \
835
+ patch("wisdom.local.up") as up:
836
+ assert mcp._try_autostart_local() is False
837
+ up.assert_not_called()
838
+
839
+
840
+ def test_try_autostart_local_starts_backend_when_docker_present():
841
+ import wisdom.mcp as mcp
842
+
843
+ with patch("wisdom.local.docker_daemon_available", return_value=True), \
844
+ patch("wisdom.local.up") as up:
845
+ assert mcp._try_autostart_local() is True
846
+ up.assert_called_once_with(connect=True)
@@ -265,7 +265,11 @@ def _run_quickstart() -> None:
265
265
 
266
266
  if storage == "local":
267
267
  from wisdom.local import up as local_up
268
- local_up()
268
+ local_up(
269
+ password=_get_arg("--password", None),
270
+ image=_get_arg("--image", None),
271
+ engine=_get_arg("--engine", None),
272
+ )
269
273
  elif storage in {"aura", "existing"}:
270
274
  uri = _get_arg("--uri", "")
271
275
  user = _get_arg("--user", "neo4j")
@@ -411,8 +415,10 @@ def main() -> None:
411
415
  from wisdom.local import down as local_down, logs as local_logs, status as local_status, up as local_up
412
416
  subcmd = sys.argv[2] if len(sys.argv) > 2 else ""
413
417
  password = _get_arg("--password", None)
418
+ image = _get_arg("--image", None)
419
+ engine = _get_arg("--engine", None)
414
420
  if subcmd == "up":
415
- local_up(password=password)
421
+ local_up(password=password, image=image, engine=engine)
416
422
  elif subcmd == "down":
417
423
  local_down()
418
424
  elif subcmd == "status":
@@ -634,8 +640,8 @@ def _print_help() -> None:
634
640
  print(" doctor check Neo4j, local backend, and MCP host readiness")
635
641
  print(" install [--platform P] copy skill (claude|windows|claw)")
636
642
  print(" connect <uri> --user U --pass P save Neo4j connection")
637
- print(" local up|down|status|logs manage first-time local Neo4j/DozerDB backend")
638
- print(" docker up|down|status manage DozerDB local container")
643
+ print(" local up [--engine neo4j|dozerdb] [--image IMAGE] [--password P]")
644
+ print(" docker up|down|status manage legacy/manual DozerDB container")
639
645
  print(" claude install|uninstall write CLAUDE.md + PreToolUse hook")
640
646
  print()
641
647
  print("MCP:")
@@ -1,7 +1,7 @@
1
- """Managed local Neo4j/DozerDB backend for first-time wisdomGraph setup."""
1
+ """Managed local Neo4j backend for first-time wisdomGraph setup."""
2
2
  from __future__ import annotations
3
3
 
4
- import secrets
4
+ import os
5
5
  import shutil
6
6
  import socket
7
7
  import stat
@@ -13,7 +13,12 @@ from pathlib import Path
13
13
  from .connect import save_connection
14
14
 
15
15
  CONTAINER_NAME = "wisdomgraph-neo4j"
16
- IMAGE = "graphstack/dozerdb:5.26.3.0"
16
+ DEFAULT_ENGINE = "neo4j"
17
+ IMAGE_BY_ENGINE = {
18
+ "neo4j": "neo4j:latest",
19
+ "dozerdb": "graphstack/dozerdb:5.26.3.0",
20
+ }
21
+ DEFAULT_PASSWORD = "password"
17
22
  BASE_DIR = Path.home() / ".wisdom" / "neo4j"
18
23
  PASSWORD_PATH = Path.home() / ".wisdom" / "local-password"
19
24
  HTTP_PORT = 7474
@@ -52,14 +57,51 @@ def _ensure_dirs() -> None:
52
57
  (BASE_DIR / subdir).mkdir(parents=True, exist_ok=True)
53
58
 
54
59
 
55
- def _read_or_create_password() -> str:
60
+ def _select_image(engine: str | None = None, image: str | None = None) -> str:
61
+ explicit_image = image or os.environ.get("WISDOM_NEO4J_IMAGE")
62
+ if explicit_image:
63
+ return explicit_image
64
+
65
+ selected_engine = (engine or os.environ.get("WISDOM_NEO4J_ENGINE") or DEFAULT_ENGINE).lower()
66
+ if selected_engine not in IMAGE_BY_ENGINE:
67
+ choices = ", ".join(sorted(IMAGE_BY_ENGINE))
68
+ print(f"error: unknown local backend engine '{selected_engine}'. Choose: {choices}", file=sys.stderr)
69
+ sys.exit(1)
70
+ return IMAGE_BY_ENGINE[selected_engine]
71
+
72
+
73
+ def _read_or_create_password(default: str = DEFAULT_PASSWORD) -> str:
56
74
  if PASSWORD_PATH.exists():
57
75
  return PASSWORD_PATH.read_text(encoding="utf-8").strip()
58
76
  PASSWORD_PATH.parent.mkdir(parents=True, exist_ok=True)
59
- password = "wg-" + secrets.token_urlsafe(24)
60
- PASSWORD_PATH.write_text(password + "\n", encoding="utf-8")
77
+ PASSWORD_PATH.write_text(default + "\n", encoding="utf-8")
61
78
  PASSWORD_PATH.chmod(stat.S_IRUSR | stat.S_IWUSR)
62
- return password
79
+ return default
80
+
81
+
82
+ def _resolve_password(password: str | None = None) -> str:
83
+ selected = password or os.environ.get("WISDOM_NEO4J_PASSWORD")
84
+ if selected:
85
+ PASSWORD_PATH.parent.mkdir(parents=True, exist_ok=True)
86
+ PASSWORD_PATH.write_text(selected + "\n", encoding="utf-8")
87
+ PASSWORD_PATH.chmod(stat.S_IRUSR | stat.S_IWUSR)
88
+ return selected
89
+ return _read_or_create_password()
90
+
91
+
92
+ def _docker_run_args(image: str, password: str) -> list[str]:
93
+ return [
94
+ "docker", "run", "-d",
95
+ "--name", CONTAINER_NAME,
96
+ "-p", f"{HTTP_PORT}:7474",
97
+ "-p", f"{BOLT_PORT}:7687",
98
+ "-v", f"{BASE_DIR}/data:/data",
99
+ "-v", f"{BASE_DIR}/logs:/logs",
100
+ "-v", f"{BASE_DIR}/import:/var/lib/neo4j/import",
101
+ "-v", f"{BASE_DIR}/plugins:/plugins",
102
+ "--env", f"NEO4J_AUTH=neo4j/{password}",
103
+ image,
104
+ ]
63
105
 
64
106
 
65
107
  def _wait_for_port(timeout_s: int = 45) -> bool:
@@ -73,8 +115,52 @@ def _wait_for_port(timeout_s: int = 45) -> bool:
73
115
  return False
74
116
 
75
117
 
76
- def up(password: str | None = None, connect: bool = True) -> None:
118
+ def _probe_cypher(password: str) -> bool:
119
+ """One-shot: can we run an authenticated `RETURN 1` yet?
120
+
121
+ Neo4j opens the Bolt port several seconds before it accepts
122
+ authenticated queries, so a TCP connect is not proof of readiness.
123
+ """
124
+ try:
125
+ from neo4j import GraphDatabase
126
+ except ImportError:
127
+ # Driver not installed here; the TCP probe is the best we can do.
128
+ return True
129
+ driver = None
130
+ try:
131
+ driver = GraphDatabase.driver(URI, auth=(USER, password))
132
+ driver.verify_connectivity()
133
+ with driver.session() as session:
134
+ session.run("RETURN 1").consume()
135
+ return True
136
+ except Exception:
137
+ return False
138
+ finally:
139
+ if driver is not None:
140
+ driver.close()
141
+
142
+
143
+ def _wait_until_ready(password: str, timeout_s: int = 90) -> bool:
144
+ """Wait until Neo4j accepts an authenticated query, not just a TCP socket."""
145
+ if not _wait_for_port(timeout_s=min(timeout_s, 45)):
146
+ return False
147
+ deadline = time.time() + timeout_s
148
+ while time.time() < deadline:
149
+ if _probe_cypher(password):
150
+ return True
151
+ time.sleep(1)
152
+ return False
153
+
154
+
155
+ def up(
156
+ password: str | None = None,
157
+ connect: bool = True,
158
+ image: str | None = None,
159
+ engine: str | None = None,
160
+ ) -> None:
77
161
  """Start the managed local backend and optionally save wisdomGraph connection."""
162
+ selected_image = _select_image(engine=engine, image=image)
163
+
78
164
  if not docker_available():
79
165
  print("error: Docker is not installed or not on PATH.", file=sys.stderr)
80
166
  print("Install Docker Desktop/Engine, or use Neo4j Aura with:", file=sys.stderr)
@@ -82,65 +168,69 @@ def up(password: str | None = None, connect: bool = True) -> None:
82
168
  sys.exit(1)
83
169
  if not docker_daemon_available():
84
170
  print("error: Docker is installed but the daemon is not reachable.", file=sys.stderr)
85
- print("Start Docker, then run: wisdom local up", file=sys.stderr)
171
+ print("Start Docker Desktop/Engine, then run: wisdom local up", file=sys.stderr)
86
172
  sys.exit(1)
87
173
 
88
- password = password or _read_or_create_password()
174
+ running = _container_id(all_containers=False)
175
+ exists = bool(running) or bool(_container_id(all_containers=True))
176
+
177
+ if exists:
178
+ # A container's NEO4J_AUTH is fixed at creation time; a new --password
179
+ # cannot change it, so reuse the saved one and warn on a mismatch.
180
+ saved = _read_or_create_password()
181
+ if password and password != saved:
182
+ print(" note: a local backend already exists — keeping its existing password.", file=sys.stderr)
183
+ print(f" To reset it: wisdom local down && docker rm {CONTAINER_NAME}, then rerun.", file=sys.stderr)
184
+ password = saved
185
+ else:
186
+ password = _resolve_password(password)
89
187
 
90
- if _container_id(all_containers=False):
188
+ if running:
91
189
  print(f" Local wisdomGraph backend already running ({CONTAINER_NAME})")
92
190
  if connect:
93
191
  save_connection(URI, USER, password)
94
- _print_ready(password)
192
+ _print_ready(password, selected_image)
95
193
  return
96
194
 
97
- if _container_id(all_containers=True):
195
+ if exists:
98
196
  print(f" Starting existing local backend ({CONTAINER_NAME})...")
99
197
  result = _run(["docker", "start", CONTAINER_NAME], capture=True)
100
198
  if result.returncode != 0:
101
199
  print(result.stderr.strip() or "error: failed to start local backend", file=sys.stderr)
102
200
  sys.exit(result.returncode)
201
+ _report_if_not_ready(password)
103
202
  if connect:
104
203
  save_connection(URI, USER, password)
105
- _print_ready(password)
204
+ _print_ready(password, selected_image)
106
205
  return
107
206
 
108
207
  _ensure_dirs()
109
208
 
110
- print(f" Pulling {IMAGE}...")
111
- result = _run(["docker", "pull", IMAGE], capture=True)
209
+ print(f" Pulling {selected_image} (first run may take a minute)...")
210
+ result = _run(["docker", "pull", selected_image]) # stream progress to the user
112
211
  if result.returncode != 0:
113
- print(result.stderr.strip() or "error: failed to pull DozerDB image", file=sys.stderr)
212
+ print(f"error: failed to pull {selected_image}", file=sys.stderr)
213
+ print("Check Docker Hub access/proxy settings, then retry: wisdom local up", file=sys.stderr)
114
214
  sys.exit(result.returncode)
115
215
 
116
216
  print(f" Starting managed local backend ({CONTAINER_NAME})...")
117
- result = _run([
118
- "docker", "run", "-d",
119
- "--name", CONTAINER_NAME,
120
- "-p", f"{HTTP_PORT}:7474",
121
- "-p", f"{BOLT_PORT}:7687",
122
- "-v", f"{BASE_DIR}/data:/data",
123
- "-v", f"{BASE_DIR}/logs:/logs",
124
- "-v", f"{BASE_DIR}/import:/var/lib/neo4j/import",
125
- "-v", f"{BASE_DIR}/plugins:/plugins",
126
- "--env", f"NEO4J_AUTH=neo4j/{password}",
127
- "--env", "NEO4J_PLUGINS=[\"apoc\"]",
128
- "--env", "NEO4J_apoc_export_file_enabled=true",
129
- "--env", "NEO4J_apoc_import_file_enabled=true",
130
- "--env", "NEO4J_dbms_security_procedures_unrestricted=*",
131
- IMAGE,
132
- ], capture=True)
217
+ result = _run(_docker_run_args(selected_image, password), capture=True)
133
218
  if result.returncode != 0:
134
219
  print(result.stderr.strip() or "error: failed to start local backend", file=sys.stderr)
135
220
  sys.exit(result.returncode)
136
221
 
137
- if not _wait_for_port():
138
- print("warning: local backend started, but Bolt was not reachable before timeout.", file=sys.stderr)
139
- print("Run `wisdom local logs` or `wisdom doctor` if connection fails.", file=sys.stderr)
222
+ print(" Waiting for Neo4j to accept connections...")
223
+ _report_if_not_ready(password)
140
224
 
141
225
  if connect:
142
226
  save_connection(URI, USER, password)
143
- _print_ready(password)
227
+ _print_ready(password, selected_image)
228
+
229
+
230
+ def _report_if_not_ready(password: str) -> None:
231
+ if not _wait_until_ready(password):
232
+ print("warning: local backend started, but Neo4j was not ready before timeout.", file=sys.stderr)
233
+ print("Run `wisdom local logs` or `wisdom doctor` if connection fails.", file=sys.stderr)
144
234
 
145
235
 
146
236
  def down() -> None:
@@ -185,13 +275,17 @@ def logs(tail: int = 80) -> None:
185
275
  print(result.stderr.rstrip(), file=sys.stderr)
186
276
 
187
277
 
188
- def _print_ready(password: str) -> None:
278
+ def _print_ready(password: str, image: str) -> None:
189
279
  print()
190
280
  print(" wisdomGraph local backend is ready")
191
281
  print()
192
282
  print(f" Container: {CONTAINER_NAME}")
283
+ print(f" Image: {image}")
193
284
  print(f" Browser: http://localhost:{HTTP_PORT}")
194
285
  print(f" Bolt URI: {URI}")
195
286
  print(f" User: {USER}")
196
- print(f" Password: stored in {PASSWORD_PATH}")
287
+ if password == DEFAULT_PASSWORD:
288
+ print(f" Password: {password}")
289
+ else:
290
+ print(f" Password: stored in {PASSWORD_PATH}")
197
291
  print()
@@ -325,16 +325,48 @@ _TOOL_DEFS: list[dict] = [
325
325
 
326
326
  # ── Handler helpers ───────────────────────────────────────────────────────────
327
327
 
328
- def _get_driver():
328
+ _CONNECT_HELP = (
329
+ "Cannot connect to Neo4j, and a managed local backend could not be started "
330
+ "automatically (Docker not available). Run `wisdom quickstart` to provision a "
331
+ "local backend, or `wisdom connect <uri> --user <u> --password <p>` to point at "
332
+ "an existing Neo4j/DozerDB/Aura instance."
333
+ )
334
+
335
+
336
+ def _try_autostart_local() -> bool:
337
+ """Best-effort: bring up the managed local backend when Docker is available.
338
+
339
+ Runs silently — stdout is redirected to stderr so `local.up`'s progress output
340
+ never corrupts the MCP stdio (JSON-RPC) stream. Returns True if it started.
341
+ """
342
+ import contextlib
343
+
344
+ try:
345
+ from . import local
346
+ except Exception:
347
+ return False
348
+ if not local.docker_daemon_available():
349
+ return False
350
+ try:
351
+ with contextlib.redirect_stdout(sys.stderr):
352
+ local.up(connect=True)
353
+ return True
354
+ except SystemExit:
355
+ return False
356
+
357
+
358
+ def _get_driver(_allow_autostart: bool = True):
329
359
  """Return a live Neo4j driver (or raise RuntimeError with a helpful message)."""
360
+ from .connect import get_driver
330
361
  try:
331
- from .connect import get_driver
332
362
  return get_driver()
333
363
  except SystemExit as e:
334
- raise RuntimeError(
335
- "Cannot connect to Neo4j. Make sure your configured Neo4j or DozerDB instance "
336
- "is running and credentials are configured (`wisdom connect`)."
337
- ) from e
364
+ if _allow_autostart and _try_autostart_local():
365
+ try:
366
+ return get_driver()
367
+ except SystemExit as e2:
368
+ raise RuntimeError(_CONNECT_HELP) from e2
369
+ raise RuntimeError(_CONNECT_HELP) from e
338
370
 
339
371
 
340
372
  # ── Tool handlers (pure Python — no mcp types needed) ────────────────────────
@@ -1,8 +1,8 @@
1
- Metadata-Version: 2.4
1
+ Metadata-Version: 2.2
2
2
  Name: wisdomgraph
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Graph-native persistent cognition for AI agents using Neo4j, DIKW, and MCP
5
- License-Expression: MIT
5
+ License: MIT
6
6
  Project-URL: Homepage, https://github.com/cklam12345/wisdomGraph
7
7
  Project-URL: Repository, https://github.com/cklam12345/wisdomGraph
8
8
  Project-URL: Issues, https://github.com/cklam12345/wisdomGraph/issues
@@ -66,7 +66,6 @@ Requires-Dist: pypdf; extra == "all"
66
66
  Requires-Dist: html2text; extra == "all"
67
67
  Requires-Dist: python-docx; extra == "all"
68
68
  Requires-Dist: openpyxl; extra == "all"
69
- Dynamic: license-file
70
69
 
71
70
  # wisdomGraph
72
71
 
@@ -108,7 +107,7 @@ wisdomGraph does something fundamentally different.
108
107
  | **Memory** | resets each session | accumulates across sessions, projects, months |
109
108
  | **Reasoning** | community detection (topology) | graph path traversal + DIKW hierarchy |
110
109
  | **Feedback loop** | none | Wisdom → Knowledge (neuroplasticity) |
111
- | **Database** | none required | Neo4j Aura (free) or DozerDB Docker |
110
+ | **Database** | none required | Neo4j Aura (free) or local Neo4j Docker |
112
111
 
113
112
  The difference is not incremental. It's architectural. graphify compresses a codebase into a readable report. wisdomGraph builds an artificial epistemology — one that remembers, connects, and grows.
114
113
 
@@ -138,7 +137,7 @@ The feedback loop is critical: when a Wisdom node is queried and found useful, i
138
137
 
139
138
  **Requires:** Python 3.10+ and one of: [Claude Code](https://claude.ai/code), [Codex](https://openai.com/codex), [OpenClaw](https://openclaw.ai), or another MCP host
140
139
 
141
- **And one of:** [Neo4j Aura Free](https://neo4j.com/cloud/platform/aura-graph-database/) (cloud, no install) or [DozerDB](https://dozerdb.org) (local Docker, APOC included)
140
+ **And one of:** [Neo4j Aura Free](https://neo4j.com/cloud/platform/aura-graph-database/) (cloud, no install) or Docker Desktop/Engine for a managed local Neo4j container
142
141
 
143
142
  ```bash
144
143
  pip install 'wisdomgraph[mcp]'
@@ -148,7 +147,7 @@ wisdom quickstart
148
147
  `wisdom quickstart` is the end-to-end first-time setup. It prepares storage, verifies the Neo4j connection, and registers wisdomGraph with detected MCP hosts.
149
148
 
150
149
  ```bash
151
- # Local managed Neo4j/DozerDB backend + detected MCP hosts
150
+ # Local managed Neo4j backend + detected MCP hosts
152
151
  wisdom quickstart
153
152
 
154
153
  # Local backend + Codex only
@@ -170,7 +169,7 @@ wisdom local up
170
169
  wisdom doctor
171
170
  ```
172
171
 
173
- This starts a managed DozerDB/Neo4j container named `wisdomgraph-neo4j`, stores data under `~/.wisdom/neo4j`, generates a local password, saves the connection, and leaves MCP startup cleanly separate.
172
+ This starts a managed `neo4j:latest` container named `wisdomgraph-neo4j`, stores data under `~/.wisdom/neo4j`, uses the documented local login `neo4j/password`, saves the connection, and leaves MCP startup cleanly separate. The implementation uses the Docker CLI directly, so the same `wisdom local up` command works from Windows PowerShell, Windows cmd.exe, macOS Terminal, and Ubuntu Terminal after Docker is installed.
174
173
 
175
174
  Useful commands:
176
175
 
@@ -192,7 +191,7 @@ wisdom connect bolt+s://xxxxxxxx.databases.neo4j.io --user neo4j --password <you
192
191
 
193
192
  Free tier: 200,000 nodes. Enough for years of accumulated wisdom.
194
193
 
195
- ### Option C — Legacy/manual DozerDB Docker (full control, APOC included)
194
+ ### Option C — Optional/manual DozerDB Docker (full control, APOC included)
196
195
 
197
196
  ```bash
198
197
  wisdom docker up # pulls graphstack/dozerdb:5.26.3.0 and starts it
File without changes
File without changes
File without changes
File without changes
File without changes