memgraph-context-graph 0.8.0__tar.gz → 0.10.0__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 (90) hide show
  1. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/CONTEXT.md +4 -0
  2. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/PKG-INFO +135 -7
  3. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/README.md +133 -5
  4. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/docs/command-hooks.md +11 -10
  5. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/pyproject.toml +2 -2
  6. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/__init__.py +2 -0
  7. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/adapters/_identity.py +58 -12
  8. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/capture_log.py +35 -0
  9. memgraph_context_graph-0.10.0/src/memgraph_context_graph/capture_policy.py +194 -0
  10. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/cli.py +205 -80
  11. memgraph_context_graph-0.10.0/src/memgraph_context_graph/connectors.py +115 -0
  12. memgraph_context_graph-0.10.0/src/memgraph_context_graph/forget.py +116 -0
  13. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/hooks/cli.py +6 -3
  14. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/hooks/runner.py +30 -112
  15. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/link.py +12 -2
  16. memgraph_context_graph-0.10.0/src/memgraph_context_graph/session.py +84 -0
  17. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/setup/agents.py +40 -6
  18. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/setup/cli.py +67 -6
  19. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/setup/engine.py +18 -4
  20. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/setup/prompts.py +111 -6
  21. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/setup/tool.py +31 -17
  22. memgraph_context_graph-0.10.0/src/memgraph_context_graph/setup/uninstall.py +245 -0
  23. memgraph_context_graph-0.10.0/src/memgraph_context_graph/setup/update.py +124 -0
  24. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/conftest.py +24 -0
  25. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/fake_agent_cli.py +19 -4
  26. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_capture_log.py +19 -2
  27. memgraph_context_graph-0.10.0/tests/test_capture_policy.py +190 -0
  28. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_config_cli.py +49 -0
  29. memgraph_context_graph-0.10.0/tests/test_connectors.py +55 -0
  30. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_dev_scripts.py +3 -1
  31. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_hook_cli.py +53 -12
  32. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_identity.py +38 -7
  33. memgraph_context_graph-0.10.0/tests/test_session.py +85 -0
  34. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_setup.py +279 -16
  35. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_setup_docker.py +12 -0
  36. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_tools.py +2 -1
  37. memgraph_context_graph-0.8.0/src/memgraph_context_graph/setup/uninstall.py +0 -116
  38. memgraph_context_graph-0.8.0/tests/test_runner_sessions_graph_connector.py +0 -81
  39. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/.gitignore +0 -0
  40. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/LICENSE +0 -0
  41. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/docs/adr/0001-runtime-adapter-terminology.md +0 -0
  42. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/docs/adr/0002-config-file-only-hook-resolution.md +0 -0
  43. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/docs/adr/0003-config-path-override.md +0 -0
  44. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/docs/adr/0004-user-id-in-session-start-event.md +0 -0
  45. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/docs/adr/0005-config-file-covers-llm-key-and-subprocess-env.md +0 -0
  46. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/docs/adr/0006-memory-tool-writes-explicit-memory.md +0 -0
  47. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/docs/research/2026-10-codex-memory.md +0 -0
  48. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/adapters/__init__.py +0 -0
  49. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/adapters/_opencode_plugin.js +0 -0
  50. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/adapters/_spec.py +0 -0
  51. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/adapters/agent_mcp.py +0 -0
  52. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/adapters/agent_memory.py +0 -0
  53. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/adapters/antigravity_cli.py +0 -0
  54. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/adapters/claude.py +0 -0
  55. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/adapters/claude_code.py +0 -0
  56. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/adapters/claude_code_memory.py +0 -0
  57. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/adapters/codex.py +0 -0
  58. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/adapters/codex_memory.py +0 -0
  59. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/adapters/copilot_cli.py +0 -0
  60. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/adapters/cursor.py +0 -0
  61. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/adapters/grok.py +0 -0
  62. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/adapters/openai.py +0 -0
  63. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/adapters/opencode.py +0 -0
  64. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/events.py +0 -0
  65. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/hooks/__init__.py +0 -0
  66. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/hooks/runtime_plugin.py +0 -0
  67. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/mcp_server.py +0 -0
  68. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/memory_backend.py +0 -0
  69. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/protocols.py +0 -0
  70. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/setup/__init__.py +0 -0
  71. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/setup/memgraph.py +0 -0
  72. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/spaces.py +0 -0
  73. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/terminal.py +0 -0
  74. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/src/memgraph_context_graph/tools.py +0 -0
  75. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/__init__.py +0 -0
  76. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_agent_memory_wiring.py +0 -0
  77. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_antigravity_cli_adapter.py +0 -0
  78. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_claude_code_adapter.py +0 -0
  79. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_codex_adapter.py +0 -0
  80. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_context_before_tool.py +0 -0
  81. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_copilot_cli_adapter.py +0 -0
  82. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_cursor_adapter.py +0 -0
  83. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_events.py +0 -0
  84. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_grok_adapter.py +0 -0
  85. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_link.py +0 -0
  86. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_opencode_adapter.py +0 -0
  87. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_plugin_hooks.py +0 -0
  88. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_runtime_plugin.py +0 -0
  89. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_spaces.py +0 -0
  90. {memgraph_context_graph-0.8.0 → memgraph_context_graph-0.10.0}/tests/test_terminal.py +0 -0
@@ -74,6 +74,10 @@ _Avoid_: Runtime Plugin (already means distribution package), Runtime Adapter (a
74
74
  Object implementing `Tool` (`tools.py`): a name, a description the model reads, an input schema, the connector whose graph it reads, an optional session-start hint, and `call(arguments, config)`. A graph component publishes it via the `memgraph_context_graph.tools` entry-point group; `memgraph-context-graph mcp` serves every registered tool, and the CLI runs one by name. Identity + connection come from the **Space Resolver** over **Hook Configuration**, never from tool arguments.
75
75
  _Avoid_: MCP tool (the protocol it is served over, not the thing), Graph Connector (writes events; a tool reads)
76
76
 
77
+ **Connector Registration**:
78
+ `ConnectorSpec` (`connectors.py`): a graph component's name, its graph class, how to build its **Graph Connector** from **Hook Configuration**, and an optional `doctor` check. Published via the `memgraph_context_graph.connectors` entry-point group; the hook runner, schema setup and `doctor` find connectors only through it. The hub keeps just what it needs before a component is installed: each installable connector's requirement (`INSTALLABLE`) and the default set.
79
+ _Avoid_: Component (the package), Graph Connector (the object a registration builds)
80
+
77
81
  ## Relationships
78
82
 
79
83
  - **Memgraph Context Graph** belongs to broader **Context Graph** family.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: memgraph-context-graph
3
- Version: 0.8.0
3
+ Version: 0.10.0
4
4
  Summary: Connect agent SDKs to context-graph components (actions-graph, skills-graph, etc.)
5
5
  License: MIT
6
6
  License-File: LICENSE
@@ -9,7 +9,7 @@ Classifier: Programming Language :: Python :: 3.11
9
9
  Classifier: Programming Language :: Python :: 3.12
10
10
  Classifier: Programming Language :: Python :: 3.13
11
11
  Requires-Python: >=3.10
12
- Requires-Dist: memgraph-toolbox>=0.1.11
12
+ Requires-Dist: memgraph-toolbox>=0.2.2
13
13
  Requires-Dist: tomlkit<1,>=0.13
14
14
  Provides-Extra: claude
15
15
  Requires-Dist: claude-agent-sdk>=0.1.0; extra == 'claude'
@@ -202,7 +202,9 @@ memgraph-context-graph setup # interactive on a terminal; pl
202
202
  memgraph-context-graph setup claude-code codex # just these agents
203
203
  memgraph-context-graph setup cursor --project-dir ~/work/billing
204
204
  memgraph-context-graph setup --plan # print the plan, change nothing
205
- memgraph-context-graph uninstall [runtime ...] # remove the wiring; the graph and config stay
205
+ memgraph-context-graph update [runtime ...] # upgrade the package, refresh the wiring and the schema
206
+ memgraph-context-graph uninstall [runtime ...] # remove the wiring; asks about the graph, config and tool
207
+ memgraph-context-graph uninstall --all # the wiring, the graph, the config and the tool
206
208
  ```
207
209
 
208
210
  It finds or starts Memgraph (a `memgraph-mage` container with a volume, on a free port when 7687 is taken),
@@ -211,6 +213,23 @@ wires each agent, and runs `doctor`'s checks. Every step checks before it acts,
211
213
  missing. The TUI starts only when stdin and stdout are both terminals; the plugins' `scripts/bootstrap.sh`
212
214
  runs `setup <runtime> --no-tui`.
213
215
 
216
+ **Uninstalling.** `uninstall` always removes the wiring (plugins, hook files, MCP entries) and gives each
217
+ agent its own memory back. On a terminal it then asks, one question each and every answer defaulting to
218
+ keep, whether to delete the graph (setup's Memgraph container and its volume: every session, for good), the
219
+ config and capture-failure log, and the uv tool. Without a terminal only the flags remove more: `--graph`,
220
+ `--config`, `--tool`, or `--all` for the three. A Memgraph you run yourself is never touched; only the
221
+ container setup started, by name (`--memgraph-container`). On Windows the running tool can't remove itself,
222
+ so it prints the `uv tool uninstall` command to run next.
223
+
224
+ **Updating.** Upgrading the package moves the code hooks and the MCP server run, but what setup wrote once stays
225
+ as it was. `update` upgrades the uv tool and its connectors, then, with the new release, refreshes everything
226
+ that is wired: Claude Code's and Codex's plugin (marketplace refreshed, plugin updated), each per-project agent's
227
+ hook file in `--project-dir` (default: the current directory) and its MCP registration, and the graph's indexes
228
+ and constraints. It then runs `doctor`'s checks. Name runtimes to refresh only those; `--no-upgrade` skips the
229
+ package step. Your own hooks, the config and the graph's data are untouched, and running it again changes nothing.
230
+ Running agent sessions keep the hooks they loaded: restart them. Outside the uv tool (a virtualenv, say) the
231
+ package step only warns, and you upgrade it yourself first.
232
+
214
233
  **Identity and connection.** setup writes `~/.config/context-graph/config.toml`; hooks read their configuration from that file at runtime (see [Configuration](#configuration) — env vars are **not** read at hook time). To change your identity later:
215
234
 
216
235
  ```bash
@@ -246,9 +265,13 @@ OK connector:actions-graph: installed=...; memgraph=reachable
246
265
  OK connector:sessions-graph: installed=...; memgraph=reachable
247
266
  OK embeddings: BAAI/bge-small-en-v1.5 (384 dimensions) inside Memgraph
248
267
  OK mcp: serves recall
249
- OK runtime:claude-code: strict hook smoke passed
268
+ OK runtime:claude-code: connectors accept its probe event
269
+ OK plugin:claude-code: context-graph@context-graph-plugins installed and enabled
250
270
  ```
251
271
 
272
+ The `runtime:` probe runs the connectors inside `doctor` itself; `plugin:` is what says Claude Code (or Codex)
273
+ will actually call the hooks.
274
+
252
275
  > **Reconciliation is a separate step.** The connectors capture session activity, but turning a session's text into extracted entities (a `:Person`/`:Organization` graph) is done out-of-band — see [sessions-graph § reconciliation](../sessions-graph/README.md#session-reconciliation). By default a finished session is marked `reconciliation_status = 'pending'` and `sessions-graph reconcile --pending` extracts it.
253
276
 
254
277
  ### Configuration
@@ -268,6 +291,15 @@ database = "memgraph"
268
291
  [llm]
269
292
  openai_api_key = ""
270
293
  anthropic_api_key = ""
294
+ derive_model = "claude-sonnet-5-5"
295
+
296
+ [capture]
297
+ connectors = "skills-graph, actions-graph, sessions-graph"
298
+ exclude_projects = "~/clients/*, ~/personal"
299
+ exclude_tools = "TodoWrite, mcp__vault__*"
300
+
301
+ [redact]
302
+ ticket = 'ACME-[0-9]+'
271
303
 
272
304
  [reconcile]
273
305
  auto_reconcile = true
@@ -275,12 +307,23 @@ auto_reconcile = true
275
307
  [recall]
276
308
  embedding_model = "BAAI/bge-small-en-v1.5"
277
309
  turns_k = "8"
310
+
311
+ [extraction]
312
+ model = "fastino/gliner2.5-base-v1"
313
+ entity_threshold = "0.3"
278
314
  ```
279
315
 
280
316
  `[reconcile]` turns on sessions-graph's auto-trigger reconciliation (see
281
317
  [sessions-graph § reconciliation](../sessions-graph/README.md#session-reconciliation)),
282
318
  which needs no LLM. `[llm]` is optional: a key only lets reconciliation learn
283
- the user's own ontology (`sessions-graph derive`).
319
+ the user's own ontology (`sessions-graph derive`), and `derive_model` picks
320
+ the model it calls (default `claude-sonnet-5-5` with Anthropic, `gpt-5` with OpenAI).
321
+ `[capture] connectors` is which graph connectors a hook enables when its
322
+ command names no `--connector`, from `skills-graph`, `actions-graph`,
323
+ `sessions-graph` and `resources-graph`; unset means the first three, and
324
+ an empty value enables none. Setup installs the ones it names.
325
+ The rest of `[capture]` and `[redact]` are the capture policy, applied to every
326
+ event before any connector stores it (see [Capture privacy](#capture-privacy)).
284
327
  `[reconcile]` is omitted entirely from a file setup wrote — absent
285
328
  means "never configured," distinct from an explicit `auto_reconcile = false`.
286
329
  `[recall]` is optional too: without it, recall runs with the widths the
@@ -288,6 +331,10 @@ benchmark measured; see [Recall](#recall-memory-for-the-harnesss-model).
288
331
  `[ontology]` is optional as well: `path` names a schema file the user's
289
332
  sessions are extracted under and `derive` is `extend` (the default) or
290
333
  `off`; see sessions-graph's [Ontology versions](../sessions-graph/README.md#ontology-versions).
334
+ `[extraction]` tunes how reconciliation, re-extraction and derivation read
335
+ sessions, all optional: `model` (a GLiNER2 checkpoint), `entity_threshold` and
336
+ `relation_threshold` (drop extractions below that confidence, 0 to 1), and
337
+ `chunk_size`/`chunk_overlap` (words per window); unset keys keep GLiNER2's defaults.
291
338
 
292
339
  Manage it with:
293
340
 
@@ -296,10 +343,64 @@ memgraph-context-graph config show
296
343
  memgraph-context-graph config get memgraph.url
297
344
  memgraph-context-graph config set <key> <value>
298
345
  # keys: identity.user_id, memgraph.{url,user,password,database},
299
- # llm.{openai_api_key,anthropic_api_key}, reconcile.auto_reconcile,
300
- # recall.embedding_model, ontology.{path,derive}, memory.backend
346
+ # llm.{openai_api_key,anthropic_api_key,derive_model},
347
+ # capture.{connectors,redact,max_chars,exclude_tools,exclude_projects},
348
+ # reconcile.auto_reconcile, recall.embedding_model, ontology.{path,derive}, memory.backend
349
+ # [recall] widths, [extraction] and [redact] patterns are edited in the file.
301
350
  ```
302
351
 
352
+ ### Capture privacy
353
+
354
+ Every hook event passes the capture policy before any connector sees it, so
355
+ what it removes never reaches Memgraph:
356
+
357
+ - **`<private>…</private>`** is stripped from prompts, replies and tool input
358
+ and output. An unclosed `<private>` hides the rest of that text, and a prompt
359
+ that was nothing but private isn't stored at all.
360
+ - **Secrets are redacted** to `[REDACTED:<name>]`: AWS, GitHub, Anthropic,
361
+ OpenAI, Slack, Stripe and Google keys, JWTs, PEM private keys, passwords in
362
+ URLs, and the credentials in this config file. Each `[redact]` key adds a
363
+ pattern (a Python regular expression; quote it with single quotes).
364
+ `capture.redact = false` turns redaction off; `<private>` still applies.
365
+ - **Long text is clipped** at `capture.max_chars` characters per field
366
+ (default 100000; `0` for no limit).
367
+ - **`capture.exclude_tools`** drops those tools' calls and results, by exact
368
+ name or glob (`mcp__vault__*`).
369
+ - **`capture.exclude_projects`** captures nothing from a session whose working
370
+ directory is one of these paths or globs, or inside one (`~` expands). The
371
+ agent's own hooks still answer normally, and recall still works there.
372
+
373
+ Redaction is pattern-based: it catches known credential shapes, not every
374
+ secret. What a session stored before the policy existed stays as it was.
375
+ Library callers driving `AgentLink` directly pass a `CapturePolicy` themselves.
376
+
377
+ ### Forgetting sessions
378
+
379
+ ```bash
380
+ memgraph-context-graph forget session <session-id> [<session-id> ...]
381
+ memgraph-context-graph forget project ~/work/client-repo # every session whose working directory is in it
382
+ memgraph-context-graph forget project . --dry-run # list what matches, delete nothing
383
+ ```
384
+
385
+ `forget` lists the matching sessions and asks before deleting (`--yes` skips the
386
+ question; without a terminal it is required). For each session it deletes, for
387
+ good and with no archive:
388
+
389
+ - what was captured: its Actions, the Agents only it used, its skill uses and
390
+ resource Touches;
391
+ - what was derived from it: its Chunks, entity mentions and extracted
392
+ relationships, any entity left with no other evidence, and the `anon-` User
393
+ made up for it;
394
+ - its lines in the local capture-failure log.
395
+
396
+ What anything else still backs stays: entities other sessions mention, Skills,
397
+ public Resources, and your memory files, including ones the session wrote (their
398
+ versions just stop naming it). A forgotten session leaves only a
399
+ `(:ForgottenSession {session_id})` marker, which stops a hook still running, a
400
+ reconciliation in progress, or a later resume of the same session from capturing
401
+ it again. It runs against your own graph; in Enterprise, shared spaces are not
402
+ touched.
403
+
303
404
  Hooks never read environment variables for these values, and neither does setup: it writes only
304
405
  `memgraph.url` and `identity.user_id`, from its flags or what it found. Everything else is set with
305
406
  `config set`, and setup leaves it alone when it rewrites the file.
@@ -355,6 +456,7 @@ from the tool call, so a model can only read its own user's sessions.
355
456
  | `facts_k`, `fact_turns_k` | `15`, `8` | Facts matched, and the messages they were read from |
356
457
  | `user_fact_types`, `user_facts_k` | `2`, `30` | Relation types gathered whole, for counting questions |
357
458
  | `turn_chars` | `1500` | Characters shown per message |
459
+ | `query_instruction` | per model | Prefix embedded with the question; bge's English models get their retrieval instruction, other models none |
358
460
 
359
461
  Recall needs Memgraph with MAGE (`memgraph/memgraph-mage`) for its vector lanes;
360
462
  without it, it answers from text search and says so. `doctor` checks both
@@ -684,6 +786,32 @@ class MyGraphConnector(GraphConnector):
684
786
  ...
685
787
  ```
686
788
 
789
+ Then register it, so hooks, schema setup and `doctor` can find it:
790
+
791
+ ```python
792
+ from memgraph_context_graph.connectors import ConnectorSpec
793
+
794
+ CONNECTOR = ConnectorSpec(
795
+ name="my-graph",
796
+ graph=MyGraph, # called with a Memgraph client, or its connection keyword arguments
797
+ build=lambda graph, config: MyGraphConnector(graph), # config: the config file's HookConfig
798
+ check=None, # optional: (config) -> (ok, detail) for doctor, beyond a reachable Memgraph
799
+ )
800
+ ```
801
+
802
+ ```toml
803
+ [project.entry-points."memgraph_context_graph.connectors"]
804
+ my-graph = "my_graph.connector:CONNECTOR"
805
+ ```
806
+
807
+ Once installed, `hook run <runtime> --connector my-graph`, `[capture] connectors = ["my-graph"]` and
808
+ `doctor` work like the built-in connectors. `setup` only installs the connectors listed in
809
+ `memgraph_context_graph.connectors.INSTALLABLE`; install your own package beside the tool yourself.
810
+
811
+ Give the component's graph class a `forget_session(session_id) -> dict[str, int]`
812
+ that deletes what it hangs off that Session and returns counts, and add it to
813
+ `FORGET_ORDER` in `memgraph_context_graph/forget.py`, so `forget` reaches it.
814
+
687
815
  ## License
688
816
 
689
817
  MIT
@@ -177,7 +177,9 @@ memgraph-context-graph setup # interactive on a terminal; pl
177
177
  memgraph-context-graph setup claude-code codex # just these agents
178
178
  memgraph-context-graph setup cursor --project-dir ~/work/billing
179
179
  memgraph-context-graph setup --plan # print the plan, change nothing
180
- memgraph-context-graph uninstall [runtime ...] # remove the wiring; the graph and config stay
180
+ memgraph-context-graph update [runtime ...] # upgrade the package, refresh the wiring and the schema
181
+ memgraph-context-graph uninstall [runtime ...] # remove the wiring; asks about the graph, config and tool
182
+ memgraph-context-graph uninstall --all # the wiring, the graph, the config and the tool
181
183
  ```
182
184
 
183
185
  It finds or starts Memgraph (a `memgraph-mage` container with a volume, on a free port when 7687 is taken),
@@ -186,6 +188,23 @@ wires each agent, and runs `doctor`'s checks. Every step checks before it acts,
186
188
  missing. The TUI starts only when stdin and stdout are both terminals; the plugins' `scripts/bootstrap.sh`
187
189
  runs `setup <runtime> --no-tui`.
188
190
 
191
+ **Uninstalling.** `uninstall` always removes the wiring (plugins, hook files, MCP entries) and gives each
192
+ agent its own memory back. On a terminal it then asks, one question each and every answer defaulting to
193
+ keep, whether to delete the graph (setup's Memgraph container and its volume: every session, for good), the
194
+ config and capture-failure log, and the uv tool. Without a terminal only the flags remove more: `--graph`,
195
+ `--config`, `--tool`, or `--all` for the three. A Memgraph you run yourself is never touched; only the
196
+ container setup started, by name (`--memgraph-container`). On Windows the running tool can't remove itself,
197
+ so it prints the `uv tool uninstall` command to run next.
198
+
199
+ **Updating.** Upgrading the package moves the code hooks and the MCP server run, but what setup wrote once stays
200
+ as it was. `update` upgrades the uv tool and its connectors, then, with the new release, refreshes everything
201
+ that is wired: Claude Code's and Codex's plugin (marketplace refreshed, plugin updated), each per-project agent's
202
+ hook file in `--project-dir` (default: the current directory) and its MCP registration, and the graph's indexes
203
+ and constraints. It then runs `doctor`'s checks. Name runtimes to refresh only those; `--no-upgrade` skips the
204
+ package step. Your own hooks, the config and the graph's data are untouched, and running it again changes nothing.
205
+ Running agent sessions keep the hooks they loaded: restart them. Outside the uv tool (a virtualenv, say) the
206
+ package step only warns, and you upgrade it yourself first.
207
+
189
208
  **Identity and connection.** setup writes `~/.config/context-graph/config.toml`; hooks read their configuration from that file at runtime (see [Configuration](#configuration) — env vars are **not** read at hook time). To change your identity later:
190
209
 
191
210
  ```bash
@@ -221,9 +240,13 @@ OK connector:actions-graph: installed=...; memgraph=reachable
221
240
  OK connector:sessions-graph: installed=...; memgraph=reachable
222
241
  OK embeddings: BAAI/bge-small-en-v1.5 (384 dimensions) inside Memgraph
223
242
  OK mcp: serves recall
224
- OK runtime:claude-code: strict hook smoke passed
243
+ OK runtime:claude-code: connectors accept its probe event
244
+ OK plugin:claude-code: context-graph@context-graph-plugins installed and enabled
225
245
  ```
226
246
 
247
+ The `runtime:` probe runs the connectors inside `doctor` itself; `plugin:` is what says Claude Code (or Codex)
248
+ will actually call the hooks.
249
+
227
250
  > **Reconciliation is a separate step.** The connectors capture session activity, but turning a session's text into extracted entities (a `:Person`/`:Organization` graph) is done out-of-band — see [sessions-graph § reconciliation](../sessions-graph/README.md#session-reconciliation). By default a finished session is marked `reconciliation_status = 'pending'` and `sessions-graph reconcile --pending` extracts it.
228
251
 
229
252
  ### Configuration
@@ -243,6 +266,15 @@ database = "memgraph"
243
266
  [llm]
244
267
  openai_api_key = ""
245
268
  anthropic_api_key = ""
269
+ derive_model = "claude-sonnet-5-5"
270
+
271
+ [capture]
272
+ connectors = "skills-graph, actions-graph, sessions-graph"
273
+ exclude_projects = "~/clients/*, ~/personal"
274
+ exclude_tools = "TodoWrite, mcp__vault__*"
275
+
276
+ [redact]
277
+ ticket = 'ACME-[0-9]+'
246
278
 
247
279
  [reconcile]
248
280
  auto_reconcile = true
@@ -250,12 +282,23 @@ auto_reconcile = true
250
282
  [recall]
251
283
  embedding_model = "BAAI/bge-small-en-v1.5"
252
284
  turns_k = "8"
285
+
286
+ [extraction]
287
+ model = "fastino/gliner2.5-base-v1"
288
+ entity_threshold = "0.3"
253
289
  ```
254
290
 
255
291
  `[reconcile]` turns on sessions-graph's auto-trigger reconciliation (see
256
292
  [sessions-graph § reconciliation](../sessions-graph/README.md#session-reconciliation)),
257
293
  which needs no LLM. `[llm]` is optional: a key only lets reconciliation learn
258
- the user's own ontology (`sessions-graph derive`).
294
+ the user's own ontology (`sessions-graph derive`), and `derive_model` picks
295
+ the model it calls (default `claude-sonnet-5-5` with Anthropic, `gpt-5` with OpenAI).
296
+ `[capture] connectors` is which graph connectors a hook enables when its
297
+ command names no `--connector`, from `skills-graph`, `actions-graph`,
298
+ `sessions-graph` and `resources-graph`; unset means the first three, and
299
+ an empty value enables none. Setup installs the ones it names.
300
+ The rest of `[capture]` and `[redact]` are the capture policy, applied to every
301
+ event before any connector stores it (see [Capture privacy](#capture-privacy)).
259
302
  `[reconcile]` is omitted entirely from a file setup wrote — absent
260
303
  means "never configured," distinct from an explicit `auto_reconcile = false`.
261
304
  `[recall]` is optional too: without it, recall runs with the widths the
@@ -263,6 +306,10 @@ benchmark measured; see [Recall](#recall-memory-for-the-harnesss-model).
263
306
  `[ontology]` is optional as well: `path` names a schema file the user's
264
307
  sessions are extracted under and `derive` is `extend` (the default) or
265
308
  `off`; see sessions-graph's [Ontology versions](../sessions-graph/README.md#ontology-versions).
309
+ `[extraction]` tunes how reconciliation, re-extraction and derivation read
310
+ sessions, all optional: `model` (a GLiNER2 checkpoint), `entity_threshold` and
311
+ `relation_threshold` (drop extractions below that confidence, 0 to 1), and
312
+ `chunk_size`/`chunk_overlap` (words per window); unset keys keep GLiNER2's defaults.
266
313
 
267
314
  Manage it with:
268
315
 
@@ -271,10 +318,64 @@ memgraph-context-graph config show
271
318
  memgraph-context-graph config get memgraph.url
272
319
  memgraph-context-graph config set <key> <value>
273
320
  # keys: identity.user_id, memgraph.{url,user,password,database},
274
- # llm.{openai_api_key,anthropic_api_key}, reconcile.auto_reconcile,
275
- # recall.embedding_model, ontology.{path,derive}, memory.backend
321
+ # llm.{openai_api_key,anthropic_api_key,derive_model},
322
+ # capture.{connectors,redact,max_chars,exclude_tools,exclude_projects},
323
+ # reconcile.auto_reconcile, recall.embedding_model, ontology.{path,derive}, memory.backend
324
+ # [recall] widths, [extraction] and [redact] patterns are edited in the file.
276
325
  ```
277
326
 
327
+ ### Capture privacy
328
+
329
+ Every hook event passes the capture policy before any connector sees it, so
330
+ what it removes never reaches Memgraph:
331
+
332
+ - **`<private>…</private>`** is stripped from prompts, replies and tool input
333
+ and output. An unclosed `<private>` hides the rest of that text, and a prompt
334
+ that was nothing but private isn't stored at all.
335
+ - **Secrets are redacted** to `[REDACTED:<name>]`: AWS, GitHub, Anthropic,
336
+ OpenAI, Slack, Stripe and Google keys, JWTs, PEM private keys, passwords in
337
+ URLs, and the credentials in this config file. Each `[redact]` key adds a
338
+ pattern (a Python regular expression; quote it with single quotes).
339
+ `capture.redact = false` turns redaction off; `<private>` still applies.
340
+ - **Long text is clipped** at `capture.max_chars` characters per field
341
+ (default 100000; `0` for no limit).
342
+ - **`capture.exclude_tools`** drops those tools' calls and results, by exact
343
+ name or glob (`mcp__vault__*`).
344
+ - **`capture.exclude_projects`** captures nothing from a session whose working
345
+ directory is one of these paths or globs, or inside one (`~` expands). The
346
+ agent's own hooks still answer normally, and recall still works there.
347
+
348
+ Redaction is pattern-based: it catches known credential shapes, not every
349
+ secret. What a session stored before the policy existed stays as it was.
350
+ Library callers driving `AgentLink` directly pass a `CapturePolicy` themselves.
351
+
352
+ ### Forgetting sessions
353
+
354
+ ```bash
355
+ memgraph-context-graph forget session <session-id> [<session-id> ...]
356
+ memgraph-context-graph forget project ~/work/client-repo # every session whose working directory is in it
357
+ memgraph-context-graph forget project . --dry-run # list what matches, delete nothing
358
+ ```
359
+
360
+ `forget` lists the matching sessions and asks before deleting (`--yes` skips the
361
+ question; without a terminal it is required). For each session it deletes, for
362
+ good and with no archive:
363
+
364
+ - what was captured: its Actions, the Agents only it used, its skill uses and
365
+ resource Touches;
366
+ - what was derived from it: its Chunks, entity mentions and extracted
367
+ relationships, any entity left with no other evidence, and the `anon-` User
368
+ made up for it;
369
+ - its lines in the local capture-failure log.
370
+
371
+ What anything else still backs stays: entities other sessions mention, Skills,
372
+ public Resources, and your memory files, including ones the session wrote (their
373
+ versions just stop naming it). A forgotten session leaves only a
374
+ `(:ForgottenSession {session_id})` marker, which stops a hook still running, a
375
+ reconciliation in progress, or a later resume of the same session from capturing
376
+ it again. It runs against your own graph; in Enterprise, shared spaces are not
377
+ touched.
378
+
278
379
  Hooks never read environment variables for these values, and neither does setup: it writes only
279
380
  `memgraph.url` and `identity.user_id`, from its flags or what it found. Everything else is set with
280
381
  `config set`, and setup leaves it alone when it rewrites the file.
@@ -330,6 +431,7 @@ from the tool call, so a model can only read its own user's sessions.
330
431
  | `facts_k`, `fact_turns_k` | `15`, `8` | Facts matched, and the messages they were read from |
331
432
  | `user_fact_types`, `user_facts_k` | `2`, `30` | Relation types gathered whole, for counting questions |
332
433
  | `turn_chars` | `1500` | Characters shown per message |
434
+ | `query_instruction` | per model | Prefix embedded with the question; bge's English models get their retrieval instruction, other models none |
333
435
 
334
436
  Recall needs Memgraph with MAGE (`memgraph/memgraph-mage`) for its vector lanes;
335
437
  without it, it answers from text search and says so. `doctor` checks both
@@ -659,6 +761,32 @@ class MyGraphConnector(GraphConnector):
659
761
  ...
660
762
  ```
661
763
 
764
+ Then register it, so hooks, schema setup and `doctor` can find it:
765
+
766
+ ```python
767
+ from memgraph_context_graph.connectors import ConnectorSpec
768
+
769
+ CONNECTOR = ConnectorSpec(
770
+ name="my-graph",
771
+ graph=MyGraph, # called with a Memgraph client, or its connection keyword arguments
772
+ build=lambda graph, config: MyGraphConnector(graph), # config: the config file's HookConfig
773
+ check=None, # optional: (config) -> (ok, detail) for doctor, beyond a reachable Memgraph
774
+ )
775
+ ```
776
+
777
+ ```toml
778
+ [project.entry-points."memgraph_context_graph.connectors"]
779
+ my-graph = "my_graph.connector:CONNECTOR"
780
+ ```
781
+
782
+ Once installed, `hook run <runtime> --connector my-graph`, `[capture] connectors = ["my-graph"]` and
783
+ `doctor` work like the built-in connectors. `setup` only installs the connectors listed in
784
+ `memgraph_context_graph.connectors.INSTALLABLE`; install your own package beside the tool yourself.
785
+
786
+ Give the component's graph class a `forget_session(session_id) -> dict[str, int]`
787
+ that deletes what it hangs off that Session and returns counts, and add it to
788
+ `FORGET_ORDER` in `memgraph_context_graph/forget.py`, so `forget` reaches it.
789
+
662
790
  ## License
663
791
 
664
792
  MIT
@@ -5,12 +5,13 @@ Protocol, then routes those events to graph connectors. The installed command
5
5
  is the same for every runtime:
6
6
 
7
7
  ```bash
8
- memgraph-context-graph hook run <runtime> \
9
- --connector skills-graph \
10
- --connector actions-graph \
11
- --connector sessions-graph
8
+ memgraph-context-graph hook run <runtime>
12
9
  ```
13
10
 
11
+ It enables the graph connectors the config file's `[capture] connectors`
12
+ names (unset: `skills-graph`, `actions-graph`, `sessions-graph`). Repeated
13
+ `--connector` flags override that for one hook command.
14
+
14
15
  Runtime registrations are discovered through the
15
16
  `memgraph_context_graph.runtimes` Python entry-point group.
16
17
 
@@ -36,8 +37,9 @@ memgraph-context-graph hook init antigravity-cli
36
37
  memgraph-context-graph hook init grok
37
38
  ```
38
39
 
39
- `hook init` enables all three built-in connectors by default. Use repeated
40
- `--connector` flags to select a subset. Existing Copilot, Cursor, Antigravity, and Grok
40
+ `hook init` writes hook commands without `--connector` flags, so they enable
41
+ `[capture] connectors`. Repeated `--connector` flags pin a set into the
42
+ generated commands instead. Existing Copilot, Cursor, Antigravity, and Grok
41
43
  JSON documents are merged without removing unrelated settings or hooks.
42
44
  OpenCode's generated plugin is replaced only with `--force`.
43
45
 
@@ -246,12 +248,11 @@ memgraph-context-graph setup antigravity-cli --project-dir "$PWD"
246
248
  Smoke-test a registration and its configured connectors:
247
249
 
248
250
  ```bash
249
- memgraph-context-graph doctor --runtime cursor \
250
- --connector skills-graph \
251
- --connector actions-graph \
252
- --connector sessions-graph
251
+ memgraph-context-graph doctor --runtime cursor
253
252
  ```
254
253
 
254
+ `doctor` checks the `[capture] connectors` set unless `--connector` flags name others.
255
+
255
256
  Each runtime provides its own native probe payload; `doctor` does not assume
256
257
  that every runtime calls its session-end event `Stop`.
257
258
 
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "memgraph-context-graph"
3
- version = "0.8.0"
3
+ version = "0.10.0"
4
4
  description = "Connect agent SDKs to context-graph components (actions-graph, skills-graph, etc.)"
5
5
  readme = "README.md"
6
6
  license = { text = "MIT" }
@@ -12,7 +12,7 @@ classifiers = [
12
12
  "Programming Language :: Python :: 3.13",
13
13
  ]
14
14
  dependencies = [
15
- "memgraph-toolbox>=0.1.11",
15
+ "memgraph-toolbox>=0.2.2",
16
16
  # Edits ~/.codex/config.toml when switching Codex's memory, keeping the user's comments and layout.
17
17
  "tomlkit>=0.13,<1",
18
18
  ]
@@ -23,6 +23,7 @@ Quick Start::
23
23
 
24
24
  from importlib import metadata
25
25
 
26
+ from .capture_policy import CapturePolicy
26
27
  from .events import (
27
28
  AgentEndEvent,
28
29
  AgentStartEvent,
@@ -52,6 +53,7 @@ __all__ = [
52
53
  "AgentEndEvent",
53
54
  "AgentLink",
54
55
  "AgentStartEvent",
56
+ "CapturePolicy",
55
57
  "ErrorOccurredEvent",
56
58
  "Event",
57
59
  "EventType",