ompa 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.
ompa-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Micap AI
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.
ompa-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,239 @@
1
+ Metadata-Version: 2.4
2
+ Name: ompa
3
+ Version: 0.1.0
4
+ Summary: Universal AI agent memory layer — vault + palace + temporal knowledge graph
5
+ Author-email: Micap AI <info@micap.ai>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/micap-ai/ompa
8
+ Project-URL: Repository, https://github.com/micap-ai/ompa
9
+ Project-URL: Documentation, https://github.com/micap-ai/ompa#readme
10
+ Project-URL: Bug Tracker, https://github.com/micap-ai/ompa/issues
11
+ Keywords: ai,memory,agent,llm,rag,vector-database,mcp,claude,openclaw,coddex,gemini-cli,knowledge-graph,temporal,obsidian,vault
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Programming Language :: Python :: 3
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Requires-Python: >=3.10
23
+ Description-Content-Type: text/markdown
24
+ License-File: LICENSE
25
+ Requires-Dist: numpy>=1.24.0
26
+ Requires-Dist: sentence-transformers>=2.2.0
27
+ Requires-Dist: typer>=0.9.0
28
+ Requires-Dist: rich>=13.0.0
29
+ Requires-Dist: python-frontmatter>=1.1.0
30
+ Requires-Dist: watchdog>=3.0.0
31
+ Provides-Extra: dev
32
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
33
+ Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
34
+ Requires-Dist: black>=23.0.0; extra == "dev"
35
+ Requires-Dist: ruff>=0.1.0; extra == "dev"
36
+ Provides-Extra: mcp
37
+ Provides-Extra: all
38
+ Requires-Dist: chromadb>=0.4.0; extra == "all"
39
+ Requires-Dist: numpy>=1.24.0; extra == "all"
40
+ Requires-Dist: sentence-transformers>=2.2.0; extra == "all"
41
+ Requires-Dist: typer>=0.9.0; extra == "all"
42
+ Requires-Dist: rich>=13.0.0; extra == "all"
43
+ Requires-Dist: python-frontmatter>=1.1.0; extra == "all"
44
+ Requires-Dist: watchdog>=3.0.0; extra == "all"
45
+ Dynamic: license-file
46
+
47
+ # OMPA (OMPA)
48
+
49
+ > **Obsidian-MemPalace-Agnostic** — Universal AI agent memory layer
50
+
51
+ OMPA gives any AI agent persistent memory with vault conventions, palace navigation, and a temporal knowledge graph.
52
+
53
+ ## Credits & Attribution
54
+
55
+ This project is a synthesis of ideas and code from the AI agent memory community:
56
+
57
+ - **[MemPalace](https://github.com/corbt/mem_palace)** by Kyle Corbitt — The palace metaphor (wings/rooms/drawers), temporal knowledge graph design, and verbatim storage approach. MemPalace proved 96.6% R@5 on LongMemEval with raw verbatim storage.
58
+ - **[obsidian-mind](https://github.com/obsidian-ai/obsidian-mind)** — Vault structure (brain/work/org/perf), wikilink conventions, frontmatter validation, and session lifecycle patterns.
59
+ - **Claude Code / Anthropic** — Hook patterns and agent-tool interaction models.
60
+ - **OpenClaw** — Framework-agnostic agent runtime that inspired the "universal" design goal.
61
+
62
+ OMPA combines these into a framework-agnostic package that works with any AI agent runtime.
63
+
64
+ [![PyPI version](https://img.shields.io/pypi/v/ompa)](https://pypi.org/project/ompa/)
65
+ [![Python versions](https://img.shields.io/pypi/pyversions/ompa)](https://pypi.org/project/ompa/)
66
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
67
+
68
+ ## The Problem
69
+
70
+ Every AI agent starts empty every session. Important decisions get lost. Context grows expensive. `ANKI` prompts only get you so far.
71
+
72
+ ## The Solution
73
+
74
+ OMPA gives any AI agent — **Claude Code, OpenClaw, Codex, Gemini CLI, or any custom agent** — persistent, structured memory that:
75
+
76
+ - **Never forgets a decision** (vault + knowledge graph)
77
+ - **Knows where things belong** (15 message types with routing hints)
78
+ - **Survives context compaction** (verbatim storage, no summarization loss)
79
+ - **Works offline** (local sentence-transformers, zero API cost)
80
+
81
+ ## Quick Start
82
+
83
+ ```bash
84
+ pip install ompa
85
+
86
+ # Initialize a vault
87
+ ao init ./workspace
88
+
89
+ # Run your agent session, then:
90
+ ao session-start # ~2K token context injection
91
+ ao classify "We decided to go with Postgres" # Route to right folder
92
+ ao search "authentication decisions" # Semantic search
93
+ ao kg-query Kai # Query the knowledge graph
94
+ ao wrap-up # Session summary + save to vault
95
+ ```
96
+
97
+ ## How It Works
98
+
99
+ ### Three-Layer Memory Architecture
100
+
101
+ ```
102
+ ┌─────────────────────────────────────────────────────────┐
103
+ │ Layer 1: Vault (human-navigable markdown) │
104
+ │ brain/ work/ org/ perf/ ← obsidian-mind structure │
105
+ ├─────────────────────────────────────────────────────────┤
106
+ │ Layer 2: Palace (agent-accessible metadata) │
107
+ │ wings → rooms → drawers (vault file references) │
108
+ │ halls: facts, events, discoveries, preferences │
109
+ │ tunnels: cross-wing connections │
110
+ ├─────────────────────────────────────────────────────────┤
111
+ │ Layer 3: Knowledge Graph (temporal triples) │
112
+ │ SQLite: subject → predicate → object + validity window │
113
+ │ Query entity history at any point in time │
114
+ └─────────────────────────────────────────────────────────┘
115
+ ```
116
+
117
+ ### 5 Lifecycle Hooks
118
+
119
+ | Hook | Tokens | When |
120
+ |------|--------|------|
121
+ | `session_start` | ~2K | Session begins |
122
+ | `user_message` | ~100 | Each user message |
123
+ | `post_tool` | ~200 | After each tool call |
124
+ | `pre_compact` | ~100 | Before context compaction |
125
+ | `stop` | ~500 | Session ends |
126
+
127
+ ### 15 Message Types
128
+
129
+ DECISION, INCIDENT, WIN, LOSS, BLOCKER, QUESTION, SUGGESTION, REVIEW, BUG, FEATURE, LEARN, RETROSPECTIVE, ALERT, STATUS, CHORE — each with routing hints that automatically file things in the right place.
130
+
131
+ ### Semantic Search (Zero API Cost)
132
+
133
+ Uses `sentence-transformers` (all-MiniLM-L6-v2) locally. No OpenAI/Anthropic API calls for search.
134
+
135
+ ## Architecture
136
+
137
+ ```
138
+ agnostic_obsidian/
139
+ ├── core.py # OMPA main class
140
+ ├── vault.py # Vault management (brain/work/org/perf)
141
+ ├── palace.py # Palace metadata (wings/rooms/drawers)
142
+ ├── knowledge_graph.py # Temporal KG (SQLite triples)
143
+ ├── hooks.py # 5 lifecycle hooks
144
+ ├── classifier.py # 15 message types
145
+ ├── semantic.py # Local semantic search
146
+ ├── mcp_server.py # MCP protocol server (15 tools)
147
+ └── cli.py # 14 CLI commands
148
+ ```
149
+
150
+ ## MCP Server (15 Tools)
151
+
152
+ Works with **Claude Desktop, Cursor, Windsurf** natively:
153
+
154
+ ```bash
155
+ # Claude Desktop
156
+ claude mcp add ompa -- python -m agnostic_obsidian.mcp_server
157
+ ```
158
+
159
+ Tools: `ao_session_start`, `ao_classify`, `ao_search`, `ao_kg_query`, `ao_kg_add`, `ao_palace_wings`, `ao_palace_rooms`, `ao_palace_tunnel`, `ao_validate`, `ao_wrap_up`, `ao_status`, `ao_orphans`, `ao_init`, `ao_search`, `ao_stop`
160
+
161
+ ## Python API
162
+
163
+ ```python
164
+ from agnostic_obsidian import OMPA
165
+
166
+ ao = OMPA(vault_path="./workspace")
167
+
168
+ # Lifecycle
169
+ result = ao.session_start() # Returns ~2K token context injection
170
+ hint = ao.handle_message("We won the enterprise deal!")
171
+ ao.post_tool("write", {"file_path": "work/active/auth.md"})
172
+ ao.stop()
173
+
174
+ # Search
175
+ results = ao.search("authentication decisions", wing="Orion")
176
+
177
+ # Knowledge Graph
178
+ ao.kg.add_triple("Kai", "works_on", "Orion", valid_from="2025-06-01")
179
+ triples = ao.kg.query_entity("Kai")
180
+ timeline = ao.kg.timeline("Orion")
181
+
182
+ # Palace
183
+ ao.palace.create_wing("Orion", type="project")
184
+ ao.palace.create_tunnel("Kai", "Orion", "auth-migration")
185
+ traversal = ao.palace.traverse("Orion", "auth-migration")
186
+ ```
187
+
188
+ ## CLI Commands
189
+
190
+ ```
191
+ ao init ao status ao session-start ao classify
192
+ ao search ao orphans ao wrap-up ao wings
193
+ ao rooms ao tunnel ao kg-query ao kg-timeline
194
+ ao kg-stats ao validate ao rebuild-index
195
+ ```
196
+
197
+ ## Framework Agnostic
198
+
199
+ Unlike MemPalace (Claude Code + MCP only) or obsidian-mind (Claude Code hooks only), OMPA works with **any AI agent**:
200
+
201
+ | Agent | Integration |
202
+ |-------|-------------|
203
+ | OpenClaw | Python API or MCP server |
204
+ | Claude Code | Python API or MCP server |
205
+ | Codex | Python API or MCP server |
206
+ | Gemini CLI | Python API or MCP server |
207
+ | Custom agent | Python API |
208
+
209
+ ## Installation
210
+
211
+ ```bash
212
+ pip install ompa # Core only
213
+ pip install ompa[all] # All dependencies including sentence-transformers
214
+ ```
215
+
216
+ Requires Python 3.10+.
217
+
218
+ ## Why "Agnostic"?
219
+
220
+ Because memory should not be coupled to your agent framework. Build once, use anywhere. The "Universal" angle is the moat — not just another Claude Code plugin.
221
+
222
+ ## Comparison
223
+
224
+ | Feature | OMPA | MemPalace | obsidian-mind |
225
+ |---------|-----------------|------------|---------------|
226
+ | Framework | Any | Claude Code | Claude Code |
227
+ | Memory type | Vault + Palace + KG | Palace + KG | Vault only |
228
+ | Semantic search | Local (free) | ChromaDB API | QMD (paid) |
229
+ | Temporal KG | SQLite ✓ | SQLite ✓ | ✗ |
230
+ | MCP server | 15 tools | 15 tools | ✗ |
231
+ | CLI | 14 commands | ✗ | ✗ |
232
+ | Hooks | 5 lifecycle | 3 lifecycle | 3 lifecycle |
233
+ | Message types | 15 | 15 | 5 |
234
+ | Verbatim storage | ✓ | ✓ | ✗ |
235
+ | Multi-agent | ✓ | ✗ | ✗ |
236
+
237
+ ## License
238
+
239
+ MIT — Micap AI
ompa-0.1.0/README.md ADDED
@@ -0,0 +1,193 @@
1
+ # OMPA (OMPA)
2
+
3
+ > **Obsidian-MemPalace-Agnostic** — Universal AI agent memory layer
4
+
5
+ OMPA gives any AI agent persistent memory with vault conventions, palace navigation, and a temporal knowledge graph.
6
+
7
+ ## Credits & Attribution
8
+
9
+ This project is a synthesis of ideas and code from the AI agent memory community:
10
+
11
+ - **[MemPalace](https://github.com/corbt/mem_palace)** by Kyle Corbitt — The palace metaphor (wings/rooms/drawers), temporal knowledge graph design, and verbatim storage approach. MemPalace proved 96.6% R@5 on LongMemEval with raw verbatim storage.
12
+ - **[obsidian-mind](https://github.com/obsidian-ai/obsidian-mind)** — Vault structure (brain/work/org/perf), wikilink conventions, frontmatter validation, and session lifecycle patterns.
13
+ - **Claude Code / Anthropic** — Hook patterns and agent-tool interaction models.
14
+ - **OpenClaw** — Framework-agnostic agent runtime that inspired the "universal" design goal.
15
+
16
+ OMPA combines these into a framework-agnostic package that works with any AI agent runtime.
17
+
18
+ [![PyPI version](https://img.shields.io/pypi/v/ompa)](https://pypi.org/project/ompa/)
19
+ [![Python versions](https://img.shields.io/pypi/pyversions/ompa)](https://pypi.org/project/ompa/)
20
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)
21
+
22
+ ## The Problem
23
+
24
+ Every AI agent starts empty every session. Important decisions get lost. Context grows expensive. `ANKI` prompts only get you so far.
25
+
26
+ ## The Solution
27
+
28
+ OMPA gives any AI agent — **Claude Code, OpenClaw, Codex, Gemini CLI, or any custom agent** — persistent, structured memory that:
29
+
30
+ - **Never forgets a decision** (vault + knowledge graph)
31
+ - **Knows where things belong** (15 message types with routing hints)
32
+ - **Survives context compaction** (verbatim storage, no summarization loss)
33
+ - **Works offline** (local sentence-transformers, zero API cost)
34
+
35
+ ## Quick Start
36
+
37
+ ```bash
38
+ pip install ompa
39
+
40
+ # Initialize a vault
41
+ ao init ./workspace
42
+
43
+ # Run your agent session, then:
44
+ ao session-start # ~2K token context injection
45
+ ao classify "We decided to go with Postgres" # Route to right folder
46
+ ao search "authentication decisions" # Semantic search
47
+ ao kg-query Kai # Query the knowledge graph
48
+ ao wrap-up # Session summary + save to vault
49
+ ```
50
+
51
+ ## How It Works
52
+
53
+ ### Three-Layer Memory Architecture
54
+
55
+ ```
56
+ ┌─────────────────────────────────────────────────────────┐
57
+ │ Layer 1: Vault (human-navigable markdown) │
58
+ │ brain/ work/ org/ perf/ ← obsidian-mind structure │
59
+ ├─────────────────────────────────────────────────────────┤
60
+ │ Layer 2: Palace (agent-accessible metadata) │
61
+ │ wings → rooms → drawers (vault file references) │
62
+ │ halls: facts, events, discoveries, preferences │
63
+ │ tunnels: cross-wing connections │
64
+ ├─────────────────────────────────────────────────────────┤
65
+ │ Layer 3: Knowledge Graph (temporal triples) │
66
+ │ SQLite: subject → predicate → object + validity window │
67
+ │ Query entity history at any point in time │
68
+ └─────────────────────────────────────────────────────────┘
69
+ ```
70
+
71
+ ### 5 Lifecycle Hooks
72
+
73
+ | Hook | Tokens | When |
74
+ |------|--------|------|
75
+ | `session_start` | ~2K | Session begins |
76
+ | `user_message` | ~100 | Each user message |
77
+ | `post_tool` | ~200 | After each tool call |
78
+ | `pre_compact` | ~100 | Before context compaction |
79
+ | `stop` | ~500 | Session ends |
80
+
81
+ ### 15 Message Types
82
+
83
+ DECISION, INCIDENT, WIN, LOSS, BLOCKER, QUESTION, SUGGESTION, REVIEW, BUG, FEATURE, LEARN, RETROSPECTIVE, ALERT, STATUS, CHORE — each with routing hints that automatically file things in the right place.
84
+
85
+ ### Semantic Search (Zero API Cost)
86
+
87
+ Uses `sentence-transformers` (all-MiniLM-L6-v2) locally. No OpenAI/Anthropic API calls for search.
88
+
89
+ ## Architecture
90
+
91
+ ```
92
+ agnostic_obsidian/
93
+ ├── core.py # OMPA main class
94
+ ├── vault.py # Vault management (brain/work/org/perf)
95
+ ├── palace.py # Palace metadata (wings/rooms/drawers)
96
+ ├── knowledge_graph.py # Temporal KG (SQLite triples)
97
+ ├── hooks.py # 5 lifecycle hooks
98
+ ├── classifier.py # 15 message types
99
+ ├── semantic.py # Local semantic search
100
+ ├── mcp_server.py # MCP protocol server (15 tools)
101
+ └── cli.py # 14 CLI commands
102
+ ```
103
+
104
+ ## MCP Server (15 Tools)
105
+
106
+ Works with **Claude Desktop, Cursor, Windsurf** natively:
107
+
108
+ ```bash
109
+ # Claude Desktop
110
+ claude mcp add ompa -- python -m agnostic_obsidian.mcp_server
111
+ ```
112
+
113
+ Tools: `ao_session_start`, `ao_classify`, `ao_search`, `ao_kg_query`, `ao_kg_add`, `ao_palace_wings`, `ao_palace_rooms`, `ao_palace_tunnel`, `ao_validate`, `ao_wrap_up`, `ao_status`, `ao_orphans`, `ao_init`, `ao_search`, `ao_stop`
114
+
115
+ ## Python API
116
+
117
+ ```python
118
+ from agnostic_obsidian import OMPA
119
+
120
+ ao = OMPA(vault_path="./workspace")
121
+
122
+ # Lifecycle
123
+ result = ao.session_start() # Returns ~2K token context injection
124
+ hint = ao.handle_message("We won the enterprise deal!")
125
+ ao.post_tool("write", {"file_path": "work/active/auth.md"})
126
+ ao.stop()
127
+
128
+ # Search
129
+ results = ao.search("authentication decisions", wing="Orion")
130
+
131
+ # Knowledge Graph
132
+ ao.kg.add_triple("Kai", "works_on", "Orion", valid_from="2025-06-01")
133
+ triples = ao.kg.query_entity("Kai")
134
+ timeline = ao.kg.timeline("Orion")
135
+
136
+ # Palace
137
+ ao.palace.create_wing("Orion", type="project")
138
+ ao.palace.create_tunnel("Kai", "Orion", "auth-migration")
139
+ traversal = ao.palace.traverse("Orion", "auth-migration")
140
+ ```
141
+
142
+ ## CLI Commands
143
+
144
+ ```
145
+ ao init ao status ao session-start ao classify
146
+ ao search ao orphans ao wrap-up ao wings
147
+ ao rooms ao tunnel ao kg-query ao kg-timeline
148
+ ao kg-stats ao validate ao rebuild-index
149
+ ```
150
+
151
+ ## Framework Agnostic
152
+
153
+ Unlike MemPalace (Claude Code + MCP only) or obsidian-mind (Claude Code hooks only), OMPA works with **any AI agent**:
154
+
155
+ | Agent | Integration |
156
+ |-------|-------------|
157
+ | OpenClaw | Python API or MCP server |
158
+ | Claude Code | Python API or MCP server |
159
+ | Codex | Python API or MCP server |
160
+ | Gemini CLI | Python API or MCP server |
161
+ | Custom agent | Python API |
162
+
163
+ ## Installation
164
+
165
+ ```bash
166
+ pip install ompa # Core only
167
+ pip install ompa[all] # All dependencies including sentence-transformers
168
+ ```
169
+
170
+ Requires Python 3.10+.
171
+
172
+ ## Why "Agnostic"?
173
+
174
+ Because memory should not be coupled to your agent framework. Build once, use anywhere. The "Universal" angle is the moat — not just another Claude Code plugin.
175
+
176
+ ## Comparison
177
+
178
+ | Feature | OMPA | MemPalace | obsidian-mind |
179
+ |---------|-----------------|------------|---------------|
180
+ | Framework | Any | Claude Code | Claude Code |
181
+ | Memory type | Vault + Palace + KG | Palace + KG | Vault only |
182
+ | Semantic search | Local (free) | ChromaDB API | QMD (paid) |
183
+ | Temporal KG | SQLite ✓ | SQLite ✓ | ✗ |
184
+ | MCP server | 15 tools | 15 tools | ✗ |
185
+ | CLI | 14 commands | ✗ | ✗ |
186
+ | Hooks | 5 lifecycle | 3 lifecycle | 3 lifecycle |
187
+ | Message types | 15 | 15 | 5 |
188
+ | Verbatim storage | ✓ | ✓ | ✗ |
189
+ | Multi-agent | ✓ | ✗ | ✗ |
190
+
191
+ ## License
192
+
193
+ MIT — Micap AI
@@ -0,0 +1,44 @@
1
+ """
2
+ OMPA — Obsidian-MemPalace-Agnostic
3
+
4
+ Universal AI agent memory layer.
5
+ Combines obsidian-mind vault conventions + MemPalace palace structure + temporal knowledge graph.
6
+
7
+ Works with OpenClaw, Claude Code, Codex, Gemini CLI, or any AI agent.
8
+
9
+ Usage:
10
+ from ompa import AgnosticObsidian
11
+ ao = AgnosticObsidian(vault_path="./workspace")
12
+ result = ao.session_start()
13
+ hint = ao.handle_message("We decided to go with Postgres")
14
+ ao.post_tool("write", {"file_path": "work/active/auth.md"})
15
+ ao.stop()
16
+ """
17
+
18
+ __version__ = "0.1.0"
19
+
20
+ from .core import AgnosticObsidian
21
+ from .vault import Vault, Note, VaultConfig
22
+ from .palace import Palace
23
+ from .knowledge_graph import KnowledgeGraph
24
+ from .classifier import MessageClassifier, Classification, MessageType
25
+ from .hooks import HookManager, HookContext, HookResult, Hook
26
+ from .semantic import SemanticIndex, SearchResult
27
+
28
+ __all__ = [
29
+ "AgnosticObsidian",
30
+ "Vault",
31
+ "Note",
32
+ "VaultConfig",
33
+ "Palace",
34
+ "KnowledgeGraph",
35
+ "MessageClassifier",
36
+ "Classification",
37
+ "MessageType",
38
+ "HookManager",
39
+ "HookContext",
40
+ "HookResult",
41
+ "Hook",
42
+ "SemanticIndex",
43
+ "SearchResult",
44
+ ]