agent-memguard 0.1.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 (62) hide show
  1. agent_memguard-0.1.0/LICENSE +21 -0
  2. agent_memguard-0.1.0/PKG-INFO +313 -0
  3. agent_memguard-0.1.0/README.md +286 -0
  4. agent_memguard-0.1.0/pyproject.toml +50 -0
  5. agent_memguard-0.1.0/setup.cfg +4 -0
  6. agent_memguard-0.1.0/setup.py +3 -0
  7. agent_memguard-0.1.0/src/agent_memguard.egg-info/PKG-INFO +313 -0
  8. agent_memguard-0.1.0/src/agent_memguard.egg-info/SOURCES.txt +60 -0
  9. agent_memguard-0.1.0/src/agent_memguard.egg-info/dependency_links.txt +1 -0
  10. agent_memguard-0.1.0/src/agent_memguard.egg-info/entry_points.txt +2 -0
  11. agent_memguard-0.1.0/src/agent_memguard.egg-info/requires.txt +7 -0
  12. agent_memguard-0.1.0/src/agent_memguard.egg-info/top_level.txt +1 -0
  13. agent_memguard-0.1.0/src/memoryguard/__init__.py +12 -0
  14. agent_memguard-0.1.0/src/memoryguard/__main__.py +6 -0
  15. agent_memguard-0.1.0/src/memoryguard/adapters.py +606 -0
  16. agent_memguard-0.1.0/src/memoryguard/agent_binding.py +204 -0
  17. agent_memguard-0.1.0/src/memoryguard/agent_cleanup.py +172 -0
  18. agent_memguard-0.1.0/src/memoryguard/agent_locator.py +362 -0
  19. agent_memguard-0.1.0/src/memoryguard/agent_mapping.py +222 -0
  20. agent_memguard-0.1.0/src/memoryguard/agent_profiles.py +970 -0
  21. agent_memguard-0.1.0/src/memoryguard/auto_organizer.py +603 -0
  22. agent_memguard-0.1.0/src/memoryguard/change_history.py +250 -0
  23. agent_memguard-0.1.0/src/memoryguard/cli.py +971 -0
  24. agent_memguard-0.1.0/src/memoryguard/discover.py +335 -0
  25. agent_memguard-0.1.0/src/memoryguard/external_mcp_detector.py +181 -0
  26. agent_memguard-0.1.0/src/memoryguard/extractor.py +166 -0
  27. agent_memguard-0.1.0/src/memoryguard/gui.py +1717 -0
  28. agent_memguard-0.1.0/src/memoryguard/interactive.py +2046 -0
  29. agent_memguard-0.1.0/src/memoryguard/light_graph.py +520 -0
  30. agent_memguard-0.1.0/src/memoryguard/managed_store.py +381 -0
  31. agent_memguard-0.1.0/src/memoryguard/mcp_client.py +521 -0
  32. agent_memguard-0.1.0/src/memoryguard/mcp_server.py +1020 -0
  33. agent_memguard-0.1.0/src/memoryguard/memory_ir.py +361 -0
  34. agent_memguard-0.1.0/src/memoryguard/policies.py +519 -0
  35. agent_memguard-0.1.0/src/memoryguard/projection.py +245 -0
  36. agent_memguard-0.1.0/src/memoryguard/provider_adapters.py +595 -0
  37. agent_memguard-0.1.0/src/memoryguard/provider_contract.py +172 -0
  38. agent_memguard-0.1.0/src/memoryguard/release_manager.py +282 -0
  39. agent_memguard-0.1.0/src/memoryguard/report.py +246 -0
  40. agent_memguard-0.1.0/src/memoryguard/rules/__init__.py +194 -0
  41. agent_memguard-0.1.0/src/memoryguard/rules/instruction_rules.py +222 -0
  42. agent_memguard-0.1.0/src/memoryguard/rules/memory_rules.py +209 -0
  43. agent_memguard-0.1.0/src/memoryguard/rules/rag_rules.py +282 -0
  44. agent_memguard-0.1.0/src/memoryguard/rules/skill_rules.py +221 -0
  45. agent_memguard-0.1.0/src/memoryguard/schema.py +462 -0
  46. agent_memguard-0.1.0/src/memoryguard/schema_v3.py +1076 -0
  47. agent_memguard-0.1.0/src/memoryguard/semantic_dedup.py +259 -0
  48. agent_memguard-0.1.0/src/memoryguard/shared_memory_store.py +850 -0
  49. agent_memguard-0.1.0/src/memoryguard/source_registry.py +561 -0
  50. agent_memguard-0.1.0/tests/test_api_call.py +79 -0
  51. agent_memguard-0.1.0/tests/test_interactive.py +36 -0
  52. agent_memguard-0.1.0/tests/test_mcp.py +31 -0
  53. agent_memguard-0.1.0/tests/test_mcp_full.py +48 -0
  54. agent_memguard-0.1.0/tests/test_neuron.py +29 -0
  55. agent_memguard-0.1.0/tests/test_schema.py +162 -0
  56. agent_memguard-0.1.0/tests/test_v3_2_agent_binding.py +97 -0
  57. agent_memguard-0.1.0/tests/test_v3_2_agent_scan_cleanup.py +142 -0
  58. agent_memguard-0.1.0/tests/test_v3_2_auto_organizer_enhanced.py +91 -0
  59. agent_memguard-0.1.0/tests/test_v3_2_document_extract.py +97 -0
  60. agent_memguard-0.1.0/tests/test_v3_2_e2e.py +197 -0
  61. agent_memguard-0.1.0/tests/test_v3_2_external_mcp.py +90 -0
  62. agent_memguard-0.1.0/tests/test_v3_2_schema.py +264 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 MemoryGuard Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,313 @@
1
+ Metadata-Version: 2.1
2
+ Name: agent-memguard
3
+ Version: 0.1.0
4
+ Summary: Local-first MCP memory backend and governance console for coding agents
5
+ Author: MemoryGuard Contributors
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/irisxc4/memoryguard
8
+ Project-URL: Repository, https://github.com/irisxc4/memoryguard
9
+ Project-URL: Documentation, https://github.com/irisxc4/memoryguard#readme
10
+ Project-URL: Issues, https://github.com/irisxc4/memoryguard/issues
11
+ Keywords: agent,governance,memory,mcp,skill,local-first,claude,cursor,codex
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: License :: OSI Approved :: MIT License
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3 :: Only
18
+ Classifier: Topic :: Software Development :: Libraries
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ Provides-Extra: gui
23
+ Requires-Dist: pywebview>=5.0; extra == "gui"
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7.0; extra == "dev"
26
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
27
+
28
+ # MemoryGuard
29
+
30
+ > Local-first MCP memory backend and governance console for coding agents.
31
+ >
32
+ > 本地优先的 MCP 记忆后端与治理台,面向编程 Agent。([中文文档](README.zh-CN.md))
33
+
34
+ MemoryGuard lets multiple coding agents write to one shared memory layer, then
35
+ automatically organizes, quarantines, supersedes, and rolls back memories —
36
+ without turning the GUI into an approval queue.
37
+
38
+ ## What It Does
39
+
40
+ MemoryGuard provides a local MCP stdio memory backend that coding agents
41
+ (Claude Code, Codex, Cursor, and others) can write to using the same memory
42
+ mechanisms they already use. Every write is auto-organized — classified,
43
+ deduplicated, superseded, quarantined, or compressed — so the shared memory
44
+ stays clean. A governance console lets you observe, edit, merge, roll back,
45
+ and resolve conflicts after the fact, not by approving every write.
46
+
47
+ (中文:MemoryGuard 提供本地 MCP 记忆后端,Agent 按原有方式写入,系统自动整理,
48
+ GUI 事后治理——无需手动批准每次写入。)
49
+
50
+ ## Features
51
+
52
+ - **MCP memory backend** — 6 core tools: read / search / write / update / delete / status
53
+ - **Auto-organize** — classify / dedup / supersede / conflict / quarantine / derive / compress
54
+ - **Multi-agent shared memory groups** — multiple agents write to one governed memory
55
+ - **GUI governance console** — observe, edit, merge, lock, restore, roll back (not an approval queue)
56
+ - **Provider adapters** — one-command setup for Claude Code / Codex / Cursor
57
+ - **Rollback and version history** — all governance actions are versioned and reversible
58
+ - **No account, no server, no telemetry** — everything stays local
59
+
60
+ ## Quick Start
61
+
62
+ ### Install
63
+
64
+ **One-line install (recommended):**
65
+
66
+ ```bash
67
+ pip install agent-memoryguard
68
+ ```
69
+
70
+ With GUI support (optional, for desktop window):
71
+
72
+ ```bash
73
+ pip install "agent-memoryguard[gui]"
74
+ ```
75
+
76
+ **Or from source:**
77
+
78
+ ```bash
79
+ git clone https://github.com/irisxc4/memoryguard.git
80
+ cd memoryguard
81
+ pip install -e .
82
+ ```
83
+
84
+ Verify the installation:
85
+
86
+ ```bash
87
+ memoryguard doctor
88
+ ```
89
+
90
+ ### Configure your Agent
91
+
92
+ **One-line setup (auto-writes MCP config + instruction file):**
93
+
94
+ ```bash
95
+ # Claude Code
96
+ memoryguard source add . && python -m memoryguard.provider_adapters install claude
97
+
98
+ # Codex
99
+ memoryguard source add . && python -m memoryguard.provider_adapters install codex
100
+
101
+ # Cursor
102
+ memoryguard source add . && python -m memoryguard.provider_adapters install cursor
103
+ ```
104
+
105
+ Or use the MCP tool directly from your agent:
106
+
107
+ ```
108
+ memoryguard_provider_install(provider="claude")
109
+ ```
110
+
111
+ **Manual config** - see the install guides for details:
112
+
113
+ - [Claude Code](docs/install-claude-code.md)
114
+ - [Codex](docs/install-codex.md)
115
+ - [Cursor](docs/install-cursor.md)
116
+
117
+ <details>
118
+ <summary>Manual MCP config (all agents use the same server)</summary>
119
+
120
+ **Claude Code** — `.mcp.json` (project root):
121
+
122
+ ```json
123
+ {
124
+ "mcpServers": {
125
+ "memoryguard": {
126
+ "command": "python",
127
+ "args": ["-m", "memoryguard.mcp_server"]
128
+ }
129
+ }
130
+ }
131
+ ```
132
+
133
+ **Codex** — `~/.codex/config.toml`:
134
+
135
+ ```toml
136
+ [mcp_servers.memoryguard]
137
+ command = "python"
138
+ args = ["-m", "memoryguard.mcp_server"]
139
+ ```
140
+
141
+ **Cursor** — `~/.cursor/mcp.json`:
142
+
143
+ ```json
144
+ {
145
+ "mcpServers": {
146
+ "memoryguard": {
147
+ "command": "python",
148
+ "args": ["-m", "memoryguard.mcp_server"]
149
+ }
150
+ }
151
+ }
152
+ ```
153
+
154
+ </details>
155
+
156
+ ### Use
157
+
158
+ ```bash
159
+ memoryguard doctor # diagnose installation and environment
160
+ memoryguard mcp-status # query MCP memory backend status
161
+ python -m memoryguard.mcp_server # start the MCP stdio server (run by your agent)
162
+ memoryguard audit . # read-only workspace scan, generate report
163
+ memoryguard open . # open the latest report
164
+ ```
165
+
166
+ Once your agent is configured, it writes memories through the
167
+ `memoryguard_memory_write` MCP tool. MemoryGuard auto-organizes every write.
168
+ Open the GUI to observe and govern the results.
169
+
170
+ ## How It Works
171
+
172
+ MemoryGuard has three layers:
173
+
174
+ | Layer | Role |
175
+ |---|---|
176
+ | **Data layer** | Agent native memory, files, external MCP, documents — provides raw evidence, no governance |
177
+ | **Memory layer** | MemoryGuard MCP shared memory backend — the single shared source of truth; agents write here; auto-organize runs on every write |
178
+ | **Governance layer** | GUI + CLI — observe, edit, merge, lock, restore, roll back after the fact |
179
+
180
+ ```
181
+ Agent writes memory
182
+ → memoryguard_memory_write (MCP tool)
183
+ → raw event
184
+ → auto-organize (classify / dedup / supersede / conflict / quarantine / derive / compress)
185
+ → active shared memory
186
+ → GUI governance (observe / correct / override / roll back)
187
+ ```
188
+
189
+ ## Commands
190
+
191
+ | Command | Description |
192
+ |---|---|
193
+ | `audit [path]` | Read-only scan, generate report |
194
+ | `open [path]` | Open latest report in a window |
195
+ | `explain <finding_id>` | Explain a finding's evidence and risk |
196
+ | `plan <finding_ids...>` | Generate minimal fix plan (no write) |
197
+ | `apply <plan_id>` | Apply a plan: backup + patch + rescan |
198
+ | `verify` | Rescan and compare before/after |
199
+ | `undo <change_id>` | Restore from backup and re-verify |
200
+ | `source <action>` | Manage authorized sources (list / add / remove / preview) |
201
+ | `scan` | Read-only scan, build coverage ledger |
202
+ | `import <action> <bundle>` | Offline import bundle (preview / create) |
203
+ | `memory <action>` | Memory build & release (build-plan / build-apply / verify / rollback) |
204
+ | `doctor` | Diagnose installation and environment |
205
+ | `mcp-status` | Query MCP memory backend status |
206
+
207
+ ## MCP Tools
208
+
209
+ ### Memory Backend (6 core tools)
210
+
211
+ | Tool | Description |
212
+ |---|---|
213
+ | `memoryguard_memory_read` | Read a single memory record by ID |
214
+ | `memoryguard_memory_search` | Search memories by query, kind, or status |
215
+ | `memoryguard_memory_write` | Write a new memory; auto-organizes on write |
216
+ | `memoryguard_memory_update` | Update a memory (body / kind / status) |
217
+ | `memoryguard_memory_delete` | Soft-delete a memory |
218
+ | `memoryguard_memory_status` | Get shared memory group status |
219
+
220
+ ### Audit & Scan
221
+
222
+ | Tool | Description |
223
+ |---|---|
224
+ | `memoryguard_audit` | Read-only workspace scan |
225
+ | `memoryguard_explain` | Explain a finding's evidence and risk |
226
+ | `memoryguard_list_sources` | List authorized sources |
227
+ | `memoryguard_scan_summary` | Scan + coverage ledger |
228
+ | `memoryguard_neuron_graph` | Read neuron graph projection |
229
+ | `memoryguard_import_preview` | Preview an import bundle |
230
+ | `memoryguard_build_plan` | Generate a memory build plan (no write) |
231
+
232
+ ### Agent Binding
233
+
234
+ | Tool | Description |
235
+ |---|---|
236
+ | `memoryguard_binding_create` | Bind an agent to a share group |
237
+ | `memoryguard_binding_list` | List agent bindings |
238
+
239
+ ### External MCP
240
+
241
+ | Tool | Description |
242
+ |---|---|
243
+ | `memoryguard_external_mcp_list` | List imported external MCP descriptors |
244
+ | `memoryguard_external_mcp_import` | Import an external MCP descriptor (L0–L4 classification) |
245
+
246
+ ### Document & Discovery
247
+
248
+ | Tool | Description |
249
+ |---|---|
250
+ | `memoryguard_extract_memories` | Extract memory segments from a source file (read-only preview) |
251
+ | `memoryguard_accept_candidates` | Accept extracted candidates and write to shared memory |
252
+
253
+ ### Semantic & Provider
254
+
255
+ | Tool | Description |
256
+ |---|---|
257
+ | `memoryguard_semantic_check` | Check text for semantic duplicates / conflicts |
258
+ | `memoryguard_provider_install` | Install provider adapter (Claude / Codex / Cursor) |
259
+
260
+ ## Governance GUI
261
+
262
+ The GUI is a **governance console, not an approval queue**. Agents write
263
+ memories through MCP; MemoryGuard auto-organizes them. The GUI then shows you:
264
+
265
+ - Recent raw writes from agents
266
+ - Auto-organize results (classify / dedup / compress)
267
+ - Supersede chains (what was covered and why)
268
+ - Conflict queue (memories that need human arbitration)
269
+ - Quarantine queue (secrets / tokens / credentials isolated automatically)
270
+ - Derived memories (procedures / preferences from repeated behavior)
271
+
272
+ Governance actions: **edit, merge, split, lock, restore, delete, roll back**.
273
+ Every action is versioned and reversible.
274
+
275
+ ## FAQ
276
+
277
+ **Does MemoryGuard require a server or account?**
278
+ No. It runs as a local MCP stdio server. No account, no cloud, no telemetry.
279
+
280
+ **Does it fully replace my agent's native memory?**
281
+ MemoryGuard redirects writes to the MCP backend where the agent supports it.
282
+ Some agents cannot fully disable native memory — MemoryGuard uses a
283
+ redirected / observed / unsupported classification instead of pretending
284
+ everything can be turned off.
285
+
286
+ **Does the GUI approve every write?**
287
+ No. The MCP backend accepts writes and auto-organizes them. The GUI only
288
+ governs the results afterward.
289
+
290
+ **Is my memory uploaded anywhere?**
291
+ No. All data stays in a local SQLite database under `.memoryguard/`.
292
+
293
+ **Can I roll back changes?**
294
+ Yes. All governance actions are versioned. You can restore, un-supersede, and
295
+ roll back to any previous version.
296
+
297
+ ## Roadmap
298
+
299
+ - **Now (open-source core):** local MCP memory backend + auto-organize + GUI governance + provider adapters + rollback. This repository.
300
+ - **Later:** enhanced governance features (decay, derivation, governance reports). No timeline committed.
301
+ - **Later:** team and enterprise features. No timeline committed.
302
+
303
+ We do not promise dates for future features. The open-source core is designed
304
+ to be fully usable on its own.
305
+
306
+ ## License
307
+
308
+ MIT — see [LICENSE](LICENSE).
309
+
310
+ ## Contributing
311
+
312
+ See [CONTRIBUTING.md](CONTRIBUTING.md). By submitting a PR you agree to the
313
+ [CLA](CLA.md).
@@ -0,0 +1,286 @@
1
+ # MemoryGuard
2
+
3
+ > Local-first MCP memory backend and governance console for coding agents.
4
+ >
5
+ > 本地优先的 MCP 记忆后端与治理台,面向编程 Agent。([中文文档](README.zh-CN.md))
6
+
7
+ MemoryGuard lets multiple coding agents write to one shared memory layer, then
8
+ automatically organizes, quarantines, supersedes, and rolls back memories —
9
+ without turning the GUI into an approval queue.
10
+
11
+ ## What It Does
12
+
13
+ MemoryGuard provides a local MCP stdio memory backend that coding agents
14
+ (Claude Code, Codex, Cursor, and others) can write to using the same memory
15
+ mechanisms they already use. Every write is auto-organized — classified,
16
+ deduplicated, superseded, quarantined, or compressed — so the shared memory
17
+ stays clean. A governance console lets you observe, edit, merge, roll back,
18
+ and resolve conflicts after the fact, not by approving every write.
19
+
20
+ (中文:MemoryGuard 提供本地 MCP 记忆后端,Agent 按原有方式写入,系统自动整理,
21
+ GUI 事后治理——无需手动批准每次写入。)
22
+
23
+ ## Features
24
+
25
+ - **MCP memory backend** — 6 core tools: read / search / write / update / delete / status
26
+ - **Auto-organize** — classify / dedup / supersede / conflict / quarantine / derive / compress
27
+ - **Multi-agent shared memory groups** — multiple agents write to one governed memory
28
+ - **GUI governance console** — observe, edit, merge, lock, restore, roll back (not an approval queue)
29
+ - **Provider adapters** — one-command setup for Claude Code / Codex / Cursor
30
+ - **Rollback and version history** — all governance actions are versioned and reversible
31
+ - **No account, no server, no telemetry** — everything stays local
32
+
33
+ ## Quick Start
34
+
35
+ ### Install
36
+
37
+ **One-line install (recommended):**
38
+
39
+ ```bash
40
+ pip install agent-memoryguard
41
+ ```
42
+
43
+ With GUI support (optional, for desktop window):
44
+
45
+ ```bash
46
+ pip install "agent-memoryguard[gui]"
47
+ ```
48
+
49
+ **Or from source:**
50
+
51
+ ```bash
52
+ git clone https://github.com/irisxc4/memoryguard.git
53
+ cd memoryguard
54
+ pip install -e .
55
+ ```
56
+
57
+ Verify the installation:
58
+
59
+ ```bash
60
+ memoryguard doctor
61
+ ```
62
+
63
+ ### Configure your Agent
64
+
65
+ **One-line setup (auto-writes MCP config + instruction file):**
66
+
67
+ ```bash
68
+ # Claude Code
69
+ memoryguard source add . && python -m memoryguard.provider_adapters install claude
70
+
71
+ # Codex
72
+ memoryguard source add . && python -m memoryguard.provider_adapters install codex
73
+
74
+ # Cursor
75
+ memoryguard source add . && python -m memoryguard.provider_adapters install cursor
76
+ ```
77
+
78
+ Or use the MCP tool directly from your agent:
79
+
80
+ ```
81
+ memoryguard_provider_install(provider="claude")
82
+ ```
83
+
84
+ **Manual config** - see the install guides for details:
85
+
86
+ - [Claude Code](docs/install-claude-code.md)
87
+ - [Codex](docs/install-codex.md)
88
+ - [Cursor](docs/install-cursor.md)
89
+
90
+ <details>
91
+ <summary>Manual MCP config (all agents use the same server)</summary>
92
+
93
+ **Claude Code** — `.mcp.json` (project root):
94
+
95
+ ```json
96
+ {
97
+ "mcpServers": {
98
+ "memoryguard": {
99
+ "command": "python",
100
+ "args": ["-m", "memoryguard.mcp_server"]
101
+ }
102
+ }
103
+ }
104
+ ```
105
+
106
+ **Codex** — `~/.codex/config.toml`:
107
+
108
+ ```toml
109
+ [mcp_servers.memoryguard]
110
+ command = "python"
111
+ args = ["-m", "memoryguard.mcp_server"]
112
+ ```
113
+
114
+ **Cursor** — `~/.cursor/mcp.json`:
115
+
116
+ ```json
117
+ {
118
+ "mcpServers": {
119
+ "memoryguard": {
120
+ "command": "python",
121
+ "args": ["-m", "memoryguard.mcp_server"]
122
+ }
123
+ }
124
+ }
125
+ ```
126
+
127
+ </details>
128
+
129
+ ### Use
130
+
131
+ ```bash
132
+ memoryguard doctor # diagnose installation and environment
133
+ memoryguard mcp-status # query MCP memory backend status
134
+ python -m memoryguard.mcp_server # start the MCP stdio server (run by your agent)
135
+ memoryguard audit . # read-only workspace scan, generate report
136
+ memoryguard open . # open the latest report
137
+ ```
138
+
139
+ Once your agent is configured, it writes memories through the
140
+ `memoryguard_memory_write` MCP tool. MemoryGuard auto-organizes every write.
141
+ Open the GUI to observe and govern the results.
142
+
143
+ ## How It Works
144
+
145
+ MemoryGuard has three layers:
146
+
147
+ | Layer | Role |
148
+ |---|---|
149
+ | **Data layer** | Agent native memory, files, external MCP, documents — provides raw evidence, no governance |
150
+ | **Memory layer** | MemoryGuard MCP shared memory backend — the single shared source of truth; agents write here; auto-organize runs on every write |
151
+ | **Governance layer** | GUI + CLI — observe, edit, merge, lock, restore, roll back after the fact |
152
+
153
+ ```
154
+ Agent writes memory
155
+ → memoryguard_memory_write (MCP tool)
156
+ → raw event
157
+ → auto-organize (classify / dedup / supersede / conflict / quarantine / derive / compress)
158
+ → active shared memory
159
+ → GUI governance (observe / correct / override / roll back)
160
+ ```
161
+
162
+ ## Commands
163
+
164
+ | Command | Description |
165
+ |---|---|
166
+ | `audit [path]` | Read-only scan, generate report |
167
+ | `open [path]` | Open latest report in a window |
168
+ | `explain <finding_id>` | Explain a finding's evidence and risk |
169
+ | `plan <finding_ids...>` | Generate minimal fix plan (no write) |
170
+ | `apply <plan_id>` | Apply a plan: backup + patch + rescan |
171
+ | `verify` | Rescan and compare before/after |
172
+ | `undo <change_id>` | Restore from backup and re-verify |
173
+ | `source <action>` | Manage authorized sources (list / add / remove / preview) |
174
+ | `scan` | Read-only scan, build coverage ledger |
175
+ | `import <action> <bundle>` | Offline import bundle (preview / create) |
176
+ | `memory <action>` | Memory build & release (build-plan / build-apply / verify / rollback) |
177
+ | `doctor` | Diagnose installation and environment |
178
+ | `mcp-status` | Query MCP memory backend status |
179
+
180
+ ## MCP Tools
181
+
182
+ ### Memory Backend (6 core tools)
183
+
184
+ | Tool | Description |
185
+ |---|---|
186
+ | `memoryguard_memory_read` | Read a single memory record by ID |
187
+ | `memoryguard_memory_search` | Search memories by query, kind, or status |
188
+ | `memoryguard_memory_write` | Write a new memory; auto-organizes on write |
189
+ | `memoryguard_memory_update` | Update a memory (body / kind / status) |
190
+ | `memoryguard_memory_delete` | Soft-delete a memory |
191
+ | `memoryguard_memory_status` | Get shared memory group status |
192
+
193
+ ### Audit & Scan
194
+
195
+ | Tool | Description |
196
+ |---|---|
197
+ | `memoryguard_audit` | Read-only workspace scan |
198
+ | `memoryguard_explain` | Explain a finding's evidence and risk |
199
+ | `memoryguard_list_sources` | List authorized sources |
200
+ | `memoryguard_scan_summary` | Scan + coverage ledger |
201
+ | `memoryguard_neuron_graph` | Read neuron graph projection |
202
+ | `memoryguard_import_preview` | Preview an import bundle |
203
+ | `memoryguard_build_plan` | Generate a memory build plan (no write) |
204
+
205
+ ### Agent Binding
206
+
207
+ | Tool | Description |
208
+ |---|---|
209
+ | `memoryguard_binding_create` | Bind an agent to a share group |
210
+ | `memoryguard_binding_list` | List agent bindings |
211
+
212
+ ### External MCP
213
+
214
+ | Tool | Description |
215
+ |---|---|
216
+ | `memoryguard_external_mcp_list` | List imported external MCP descriptors |
217
+ | `memoryguard_external_mcp_import` | Import an external MCP descriptor (L0–L4 classification) |
218
+
219
+ ### Document & Discovery
220
+
221
+ | Tool | Description |
222
+ |---|---|
223
+ | `memoryguard_extract_memories` | Extract memory segments from a source file (read-only preview) |
224
+ | `memoryguard_accept_candidates` | Accept extracted candidates and write to shared memory |
225
+
226
+ ### Semantic & Provider
227
+
228
+ | Tool | Description |
229
+ |---|---|
230
+ | `memoryguard_semantic_check` | Check text for semantic duplicates / conflicts |
231
+ | `memoryguard_provider_install` | Install provider adapter (Claude / Codex / Cursor) |
232
+
233
+ ## Governance GUI
234
+
235
+ The GUI is a **governance console, not an approval queue**. Agents write
236
+ memories through MCP; MemoryGuard auto-organizes them. The GUI then shows you:
237
+
238
+ - Recent raw writes from agents
239
+ - Auto-organize results (classify / dedup / compress)
240
+ - Supersede chains (what was covered and why)
241
+ - Conflict queue (memories that need human arbitration)
242
+ - Quarantine queue (secrets / tokens / credentials isolated automatically)
243
+ - Derived memories (procedures / preferences from repeated behavior)
244
+
245
+ Governance actions: **edit, merge, split, lock, restore, delete, roll back**.
246
+ Every action is versioned and reversible.
247
+
248
+ ## FAQ
249
+
250
+ **Does MemoryGuard require a server or account?**
251
+ No. It runs as a local MCP stdio server. No account, no cloud, no telemetry.
252
+
253
+ **Does it fully replace my agent's native memory?**
254
+ MemoryGuard redirects writes to the MCP backend where the agent supports it.
255
+ Some agents cannot fully disable native memory — MemoryGuard uses a
256
+ redirected / observed / unsupported classification instead of pretending
257
+ everything can be turned off.
258
+
259
+ **Does the GUI approve every write?**
260
+ No. The MCP backend accepts writes and auto-organizes them. The GUI only
261
+ governs the results afterward.
262
+
263
+ **Is my memory uploaded anywhere?**
264
+ No. All data stays in a local SQLite database under `.memoryguard/`.
265
+
266
+ **Can I roll back changes?**
267
+ Yes. All governance actions are versioned. You can restore, un-supersede, and
268
+ roll back to any previous version.
269
+
270
+ ## Roadmap
271
+
272
+ - **Now (open-source core):** local MCP memory backend + auto-organize + GUI governance + provider adapters + rollback. This repository.
273
+ - **Later:** enhanced governance features (decay, derivation, governance reports). No timeline committed.
274
+ - **Later:** team and enterprise features. No timeline committed.
275
+
276
+ We do not promise dates for future features. The open-source core is designed
277
+ to be fully usable on its own.
278
+
279
+ ## License
280
+
281
+ MIT — see [LICENSE](LICENSE).
282
+
283
+ ## Contributing
284
+
285
+ See [CONTRIBUTING.md](CONTRIBUTING.md). By submitting a PR you agree to the
286
+ [CLA](CLA.md).
@@ -0,0 +1,50 @@
1
+ [project]
2
+ name = "agent-memguard"
3
+ version = "0.1.0"
4
+ description = "Local-first MCP memory backend and governance console for coding agents"
5
+ readme = "README.md"
6
+ requires-python = ">=3.10"
7
+ license = { text = "MIT" }
8
+ authors = [{ name = "MemoryGuard Contributors" }]
9
+ keywords = ["agent", "governance", "memory", "mcp", "skill", "local-first", "claude", "cursor", "codex"]
10
+ classifiers = [
11
+ "Development Status :: 3 - Alpha",
12
+ "Intended Audience :: Developers",
13
+ "License :: OSI Approved :: MIT License",
14
+ "Operating System :: OS Independent",
15
+ "Programming Language :: Python :: 3",
16
+ "Programming Language :: Python :: 3 :: Only",
17
+ "Topic :: Software Development :: Libraries",
18
+ ]
19
+ # 首期零运行时第三方依赖:纯标准库实现,保证无网络、无供应链风险。
20
+ dependencies = []
21
+
22
+ [project.urls]
23
+ Homepage = "https://github.com/irisxc4/memoryguard"
24
+ Repository = "https://github.com/irisxc4/memoryguard"
25
+ Documentation = "https://github.com/irisxc4/memoryguard#readme"
26
+ Issues = "https://github.com/irisxc4/memoryguard/issues"
27
+
28
+ [project.scripts]
29
+ memoryguard = "memoryguard.cli:main"
30
+
31
+ [project.optional-dependencies]
32
+ # 原生桌面窗口 GUI(可选)。未安装时 `open` 自动降级到 localhost/HTML。
33
+ # 引入理由: 用户需求要求原生窗口;保持可选以维持 Core 零依赖原则(spec §1.3/§10)。
34
+ gui = ["pywebview>=5.0"]
35
+ dev = [
36
+ "pytest>=7.0",
37
+ "pytest-cov>=4.0",
38
+ ]
39
+
40
+ [build-system]
41
+ requires = ["setuptools>=68", "wheel"]
42
+ build-backend = "setuptools.build_meta"
43
+
44
+ [tool.setuptools.packages.find]
45
+ where = ["src"]
46
+
47
+ [tool.pytest.ini_options]
48
+ testpaths = ["tests"]
49
+ python_files = ["test_*.py"]
50
+ addopts = "-ra --strict-markers"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,3 @@
1
+ from setuptools import setup
2
+
3
+ setup()