eling 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.
- eling-0.1.0/LICENSE +27 -0
- eling-0.1.0/PKG-INFO +102 -0
- eling-0.1.0/README.md +76 -0
- eling-0.1.0/pyproject.toml +50 -0
- eling-0.1.0/setup.cfg +4 -0
- eling-0.1.0/src/eling/__init__.py +37 -0
- eling-0.1.0/src/eling/adapters/__init__.py +202 -0
- eling-0.1.0/src/eling/brain.py +629 -0
- eling-0.1.0/src/eling/cli.py +233 -0
- eling-0.1.0/src/eling/compress.py +146 -0
- eling-0.1.0/src/eling/config.py +271 -0
- eling-0.1.0/src/eling/decay.py +63 -0
- eling-0.1.0/src/eling/export.py +198 -0
- eling-0.1.0/src/eling/hermes_plugin.py +65 -0
- eling-0.1.0/src/eling/hooks.py +396 -0
- eling-0.1.0/src/eling/layers/__init__.py +1 -0
- eling-0.1.0/src/eling/layers/builtin.py +60 -0
- eling-0.1.0/src/eling/layers/code.py +86 -0
- eling-0.1.0/src/eling/layers/code_index.py +451 -0
- eling-0.1.0/src/eling/layers/facts.py +756 -0
- eling-0.1.0/src/eling/layers/hrr.py +119 -0
- eling-0.1.0/src/eling/layers/kb.py +172 -0
- eling-0.1.0/src/eling/layers/notion.py +223 -0
- eling-0.1.0/src/eling/mcp_server.py +348 -0
- eling-0.1.0/src/eling/permissions.py +138 -0
- eling-0.1.0/src/eling/privacy.py +234 -0
- eling-0.1.0/src/eling/scripts/benchmark.py +159 -0
- eling-0.1.0/src/eling/snapshot.py +185 -0
- eling-0.1.0/src/eling/utils/__init__.py +1 -0
- eling-0.1.0/src/eling.egg-info/PKG-INFO +102 -0
- eling-0.1.0/src/eling.egg-info/SOURCES.txt +52 -0
- eling-0.1.0/src/eling.egg-info/dependency_links.txt +1 -0
- eling-0.1.0/src/eling.egg-info/requires.txt +8 -0
- eling-0.1.0/src/eling.egg-info/top_level.txt +1 -0
- eling-0.1.0/tests/test_adapters.py +180 -0
- eling-0.1.0/tests/test_brain.py +154 -0
- eling-0.1.0/tests/test_builtin.py +91 -0
- eling-0.1.0/tests/test_cli.py +175 -0
- eling-0.1.0/tests/test_compress.py +91 -0
- eling-0.1.0/tests/test_config.py +97 -0
- eling-0.1.0/tests/test_contradiction.py +191 -0
- eling-0.1.0/tests/test_decay.py +417 -0
- eling-0.1.0/tests/test_export.py +98 -0
- eling-0.1.0/tests/test_facts.py +240 -0
- eling-0.1.0/tests/test_graph.py +109 -0
- eling-0.1.0/tests/test_hooks.py +354 -0
- eling-0.1.0/tests/test_hrr.py +131 -0
- eling-0.1.0/tests/test_kb.py +124 -0
- eling-0.1.0/tests/test_permissions.py +127 -0
- eling-0.1.0/tests/test_privacy.py +301 -0
- eling-0.1.0/tests/test_schema_packs.py +78 -0
- eling-0.1.0/tests/test_snapshot.py +165 -0
- eling-0.1.0/tests/test_sync.py +192 -0
- eling-0.1.0/tests/test_think.py +109 -0
eling-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 PatrickNoFilter
|
|
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.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
This project incorporates code from the holographic memory plugin by dusterbloom
|
|
26
|
+
(Hermes Agent PR #2351, MIT). The HRR phase-encoding implementation in
|
|
27
|
+
src/eling/layers/hrr.py is adapted from that plugin.
|
eling-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: eling
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Unified second brain for AI agents — 5-tier memory, HRR reasoning, 9 MCP tools
|
|
5
|
+
Author: PatrickNoFilter
|
|
6
|
+
License: MIT
|
|
7
|
+
Keywords: memory,mcp,ai-agent,second-brain,hrr
|
|
8
|
+
Classifier: Development Status :: 4 - Beta
|
|
9
|
+
Classifier: Environment :: Console
|
|
10
|
+
Classifier: Intended Audience :: Developers
|
|
11
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Provides-Extra: hrr
|
|
20
|
+
Requires-Dist: numpy>=1.24; extra == "hrr"
|
|
21
|
+
Provides-Extra: dev
|
|
22
|
+
Requires-Dist: eling[hrr]; extra == "dev"
|
|
23
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
24
|
+
Requires-Dist: pytest-cov>=4.0; extra == "dev"
|
|
25
|
+
Dynamic: license-file
|
|
26
|
+
|
|
27
|
+
<div align="center">
|
|
28
|
+
|
|
29
|
+
# 🧠 Eling
|
|
30
|
+
|
|
31
|
+
**Unified second brain for AI agents — Hermes-first**
|
|
32
|
+
|
|
33
|
+
*"Eling" (Javanese): to remember, to be conscious, to be aware*
|
|
34
|
+
|
|
35
|
+
[](https://python.org)
|
|
36
|
+
[](LICENSE)
|
|
37
|
+
[](https://modelcontextprotocol.io)
|
|
38
|
+
[](https://github.com/NousResearch/hermes-agent)
|
|
39
|
+
|
|
40
|
+
</div>
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
## ✨ What is Eling?
|
|
45
|
+
|
|
46
|
+
Eling is a **unified second brain** for AI agents. It merges 5 memory tiers into one MCP server:
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
🧠 Layer 5: NOTION (online brain, human-readable)
|
|
50
|
+
📚 Layer 4: KB (FTS5 knowledge corpus)
|
|
51
|
+
🕸️ Layer 3: CODE (codegraph symbol intelligence)
|
|
52
|
+
💎 Layer 2: FACTS (HRR + BM25 hybrid)
|
|
53
|
+
📌 Layer 1: BUILTIN (Hermes MEMORY.md/USER.md)
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
All accessible via **5 unified tools**:
|
|
57
|
+
- `eling_remember` — smart routing across layers
|
|
58
|
+
- `eling_recall` — cross-layer search with RRF fusion
|
|
59
|
+
- `eling_reason` — compositional query (multi-entity)
|
|
60
|
+
- `eling_reflect` — promote local fact → Notion
|
|
61
|
+
- `eling_sync` — bidirectional Notion ↔ local
|
|
62
|
+
|
|
63
|
+
## 🚀 Quick Start
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install eling-memory
|
|
67
|
+
|
|
68
|
+
# As Hermes plugin
|
|
69
|
+
eling install-hermes-plugin
|
|
70
|
+
|
|
71
|
+
# As standalone MCP server
|
|
72
|
+
eling-mcp
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## 🎯 Why Eling?
|
|
76
|
+
|
|
77
|
+
| Feature | Eling | mem0 | agentmemory | Mnemosyne |
|
|
78
|
+
|---------|-------|------|-------------|-----------|
|
|
79
|
+
| **Notion as online brain** | ✅ native | ❌ | ❌ | ❌ |
|
|
80
|
+
| **codegraph integration** | ✅ embedded | ❌ | ❌ | ❌ |
|
|
81
|
+
| **FTS5 knowledge base** | ✅ embedded | ❌ | ❌ | partial |
|
|
82
|
+
| **Hermes-first design** | ✅ | indirect | indirect | ✅ |
|
|
83
|
+
| **Single MCP process** | ✅ | ❌ | ❌ | ✅ |
|
|
84
|
+
| **HRR compositional reasoning** | ✅ | ❌ | ❌ | ✅ |
|
|
85
|
+
| **Indonesian-friendly** | ✅ | ❌ | ❌ | ❌ |
|
|
86
|
+
|
|
87
|
+
## 📖 Documentation
|
|
88
|
+
|
|
89
|
+
- [Architecture](docs/architecture.md)
|
|
90
|
+
- [API Reference](docs/api.md)
|
|
91
|
+
- [Migration from holographic](docs/migration.md)
|
|
92
|
+
- [Notion setup](docs/notion-setup.md)
|
|
93
|
+
|
|
94
|
+
## 🤝 Credits
|
|
95
|
+
|
|
96
|
+
- HRR phase encoding adapted from holographic plugin by [dusterbloom](https://github.com/dusterbloom) (Hermes PR #2351, MIT)
|
|
97
|
+
- FTS5 retrieval techniques inspired by Nous Research's [context-mode](https://github.com/NousResearch/context-mode)
|
|
98
|
+
- Architecture lessons from [rohitg00/agentmemory](https://github.com/rohitg00/agentmemory) and [AxDSan/mnemosyne](https://github.com/AxDSan/mnemosyne)
|
|
99
|
+
|
|
100
|
+
## 📜 License
|
|
101
|
+
|
|
102
|
+
MIT © 2026 PatrickNoFilter
|
eling-0.1.0/README.md
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# 🧠 Eling
|
|
4
|
+
|
|
5
|
+
**Unified second brain for AI agents — Hermes-first**
|
|
6
|
+
|
|
7
|
+
*"Eling" (Javanese): to remember, to be conscious, to be aware*
|
|
8
|
+
|
|
9
|
+
[](https://python.org)
|
|
10
|
+
[](LICENSE)
|
|
11
|
+
[](https://modelcontextprotocol.io)
|
|
12
|
+
[](https://github.com/NousResearch/hermes-agent)
|
|
13
|
+
|
|
14
|
+
</div>
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
18
|
+
## ✨ What is Eling?
|
|
19
|
+
|
|
20
|
+
Eling is a **unified second brain** for AI agents. It merges 5 memory tiers into one MCP server:
|
|
21
|
+
|
|
22
|
+
```
|
|
23
|
+
🧠 Layer 5: NOTION (online brain, human-readable)
|
|
24
|
+
📚 Layer 4: KB (FTS5 knowledge corpus)
|
|
25
|
+
🕸️ Layer 3: CODE (codegraph symbol intelligence)
|
|
26
|
+
💎 Layer 2: FACTS (HRR + BM25 hybrid)
|
|
27
|
+
📌 Layer 1: BUILTIN (Hermes MEMORY.md/USER.md)
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
All accessible via **5 unified tools**:
|
|
31
|
+
- `eling_remember` — smart routing across layers
|
|
32
|
+
- `eling_recall` — cross-layer search with RRF fusion
|
|
33
|
+
- `eling_reason` — compositional query (multi-entity)
|
|
34
|
+
- `eling_reflect` — promote local fact → Notion
|
|
35
|
+
- `eling_sync` — bidirectional Notion ↔ local
|
|
36
|
+
|
|
37
|
+
## 🚀 Quick Start
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
pip install eling-memory
|
|
41
|
+
|
|
42
|
+
# As Hermes plugin
|
|
43
|
+
eling install-hermes-plugin
|
|
44
|
+
|
|
45
|
+
# As standalone MCP server
|
|
46
|
+
eling-mcp
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 🎯 Why Eling?
|
|
50
|
+
|
|
51
|
+
| Feature | Eling | mem0 | agentmemory | Mnemosyne |
|
|
52
|
+
|---------|-------|------|-------------|-----------|
|
|
53
|
+
| **Notion as online brain** | ✅ native | ❌ | ❌ | ❌ |
|
|
54
|
+
| **codegraph integration** | ✅ embedded | ❌ | ❌ | ❌ |
|
|
55
|
+
| **FTS5 knowledge base** | ✅ embedded | ❌ | ❌ | partial |
|
|
56
|
+
| **Hermes-first design** | ✅ | indirect | indirect | ✅ |
|
|
57
|
+
| **Single MCP process** | ✅ | ❌ | ❌ | ✅ |
|
|
58
|
+
| **HRR compositional reasoning** | ✅ | ❌ | ❌ | ✅ |
|
|
59
|
+
| **Indonesian-friendly** | ✅ | ❌ | ❌ | ❌ |
|
|
60
|
+
|
|
61
|
+
## 📖 Documentation
|
|
62
|
+
|
|
63
|
+
- [Architecture](docs/architecture.md)
|
|
64
|
+
- [API Reference](docs/api.md)
|
|
65
|
+
- [Migration from holographic](docs/migration.md)
|
|
66
|
+
- [Notion setup](docs/notion-setup.md)
|
|
67
|
+
|
|
68
|
+
## 🤝 Credits
|
|
69
|
+
|
|
70
|
+
- HRR phase encoding adapted from holographic plugin by [dusterbloom](https://github.com/dusterbloom) (Hermes PR #2351, MIT)
|
|
71
|
+
- FTS5 retrieval techniques inspired by Nous Research's [context-mode](https://github.com/NousResearch/context-mode)
|
|
72
|
+
- Architecture lessons from [rohitg00/agentmemory](https://github.com/rohitg00/agentmemory) and [AxDSan/mnemosyne](https://github.com/AxDSan/mnemosyne)
|
|
73
|
+
|
|
74
|
+
## 📜 License
|
|
75
|
+
|
|
76
|
+
MIT © 2026 PatrickNoFilter
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=68.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "eling"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Unified second brain for AI agents — 5-tier memory, HRR reasoning, 9 MCP tools"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
keywords = ["memory", "mcp", "ai-agent", "second-brain", "hrr"]
|
|
13
|
+
|
|
14
|
+
authors = [
|
|
15
|
+
{name = "PatrickNoFilter"},
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
classifiers = [
|
|
19
|
+
"Development Status :: 4 - Beta",
|
|
20
|
+
"Environment :: Console",
|
|
21
|
+
"Intended Audience :: Developers",
|
|
22
|
+
"License :: OSI Approved :: MIT License",
|
|
23
|
+
"Programming Language :: Python :: 3.10",
|
|
24
|
+
"Programming Language :: Python :: 3.11",
|
|
25
|
+
"Programming Language :: Python :: 3.12",
|
|
26
|
+
"Topic :: Scientific/Engineering :: Artificial Intelligence",
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
dependencies = [
|
|
30
|
+
# numpy is optional — needed only for HRR.
|
|
31
|
+
# Install via: pip install eling[hrr] or pip install eling[dev]
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
[project.optional-dependencies]
|
|
35
|
+
hrr = ["numpy>=1.24"]
|
|
36
|
+
dev = [
|
|
37
|
+
"eling[hrr]",
|
|
38
|
+
"pytest>=7.0",
|
|
39
|
+
"pytest-cov>=4.0",
|
|
40
|
+
]
|
|
41
|
+
|
|
42
|
+
[tool.setuptools.packages.find]
|
|
43
|
+
where = ["src"]
|
|
44
|
+
|
|
45
|
+
[tool.pytest.ini_options]
|
|
46
|
+
testpaths = ["tests"]
|
|
47
|
+
python_files = ["test_*.py"]
|
|
48
|
+
python_classes = ["Test*"]
|
|
49
|
+
python_functions = ["test_*"]
|
|
50
|
+
addopts = "-v --tb=short"
|
eling-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"""Eling — unified second brain for AI agents.
|
|
2
|
+
|
|
3
|
+
5-layer architecture: builtin / facts / kb / code / notion
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
__version__ = "0.1.0"
|
|
7
|
+
__all__ = ["Brain", "HookRegistry", "ALL_HOOKS", "register_default_hooks",
|
|
8
|
+
"remember", "recall", "reason", "resolve_config", "set_config_key",
|
|
9
|
+
"get_config", "describe_config"]
|
|
10
|
+
|
|
11
|
+
from .brain import Brain
|
|
12
|
+
from .hooks import HookRegistry, ALL_HOOKS, register_default_hooks
|
|
13
|
+
from .config import resolve_config, set_config_key, get_config, describe_config
|
|
14
|
+
|
|
15
|
+
_default_brain: Brain | None = None
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def _get_default() -> Brain:
|
|
19
|
+
global _default_brain
|
|
20
|
+
if _default_brain is None:
|
|
21
|
+
_default_brain = Brain()
|
|
22
|
+
return _default_brain
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
def remember(content: str, **kwargs) -> dict:
|
|
26
|
+
"""Quick-access remember on default brain."""
|
|
27
|
+
return _get_default().remember(content, **kwargs)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def recall(query: str, **kwargs) -> dict:
|
|
31
|
+
"""Quick-access recall on default brain."""
|
|
32
|
+
return _get_default().recall(query, **kwargs)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def reason(entities: list[str], **kwargs) -> list[dict]:
|
|
36
|
+
"""Quick-access reason on default brain."""
|
|
37
|
+
return _get_default().reason(entities, **kwargs)
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
"""Harness adapters — multi-agent context injection (Task 12.3).
|
|
2
|
+
|
|
3
|
+
Each adapter knows how to read its platform's memory/project file(s)
|
|
4
|
+
and report its context budget so eling can adapt what it serves.
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from __future__ import annotations
|
|
8
|
+
|
|
9
|
+
import os
|
|
10
|
+
import json
|
|
11
|
+
from abc import ABC, abstractmethod
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
from typing import Any
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
__all__ = [
|
|
17
|
+
"HarnessAdapter",
|
|
18
|
+
"HermesAdapter",
|
|
19
|
+
"ClaudeCliAdapter",
|
|
20
|
+
"OpenCodeAdapter",
|
|
21
|
+
"OpenClawAdapter",
|
|
22
|
+
"OpenClaudeAdapter",
|
|
23
|
+
"all_adapters",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# ── Context budgets (conservative estimates) ─────────────────────────
|
|
28
|
+
|
|
29
|
+
_HERMES_BUDGET = 8_192 # MEMORY.md + USER.md, typically 2-4 KB each
|
|
30
|
+
_CLAUDE_CLI_BUDGET = 32_000 # CLAUDE.md can be up to ~32 KB
|
|
31
|
+
_OPENCODE_BUDGET = 32_000 # AGENTS.md + opencode.json
|
|
32
|
+
_OPENCLAW_BUDGET = 24_000 # CLAUDE.md equivalent
|
|
33
|
+
_OPENCLAUDE_BUDGET = 24_000
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# ── Base adapter ─────────────────────────────────────────────────────
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class HarnessAdapter(ABC):
|
|
40
|
+
"""Base class for platform-specific harness adapters."""
|
|
41
|
+
|
|
42
|
+
name: str = ""
|
|
43
|
+
|
|
44
|
+
@abstractmethod
|
|
45
|
+
def read_context(self, project_root: str | Path = ".") -> str:
|
|
46
|
+
"""Read the harness's memory/context file(s)."""
|
|
47
|
+
...
|
|
48
|
+
|
|
49
|
+
@abstractmethod
|
|
50
|
+
def budget_bytes(self) -> int:
|
|
51
|
+
"""Approximate context budget in bytes."""
|
|
52
|
+
...
|
|
53
|
+
|
|
54
|
+
def default_schema_pack(self) -> str:
|
|
55
|
+
"""Recommended schema pack name for this harness."""
|
|
56
|
+
return "default"
|
|
57
|
+
|
|
58
|
+
def context_file_path(self, name: str, project_root: str | Path = ".") -> Path:
|
|
59
|
+
"""Resolve a context file name, searching cwd → parent dirs."""
|
|
60
|
+
root = Path(project_root).resolve()
|
|
61
|
+
for parent in [root] + list(root.parents):
|
|
62
|
+
candidate = parent / name
|
|
63
|
+
if candidate.is_file():
|
|
64
|
+
return candidate
|
|
65
|
+
return root / name
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
# ── Concrete adapters ────────────────────────────────────────────────
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
class HermesAdapter(HarnessAdapter):
|
|
72
|
+
"""Reads from the Hermes profile's MEMORY.md and USER.md."""
|
|
73
|
+
|
|
74
|
+
name = "hermes"
|
|
75
|
+
|
|
76
|
+
def __init__(self, hermes_home: str | Path | None = None):
|
|
77
|
+
home = Path(hermes_home) if hermes_home else Path.home() / ".hermes"
|
|
78
|
+
self._mem = home / "MEMORY.md"
|
|
79
|
+
self._usr = home / "USER.md"
|
|
80
|
+
|
|
81
|
+
def read_context(self, project_root: str | Path = ".") -> str:
|
|
82
|
+
parts: list[str] = []
|
|
83
|
+
for path, label in [(self._mem, "MEMORY"), (self._usr, "USER PROFILE")]:
|
|
84
|
+
if path.is_file():
|
|
85
|
+
parts.append(f"--- {label} ---\n{path.read_text(encoding='utf-8', errors='replace')}")
|
|
86
|
+
return "\n\n".join(parts) if parts else ""
|
|
87
|
+
|
|
88
|
+
def budget_bytes(self) -> int:
|
|
89
|
+
return _HERMES_BUDGET
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class ClaudeCliAdapter(HarnessAdapter):
|
|
93
|
+
"""Reads CLAUDE.md from the project root."""
|
|
94
|
+
|
|
95
|
+
name = "claude_cli"
|
|
96
|
+
|
|
97
|
+
def read_context(self, project_root: str | Path = ".") -> str:
|
|
98
|
+
path = self.context_file_path("CLAUDE.md", project_root)
|
|
99
|
+
if path.is_file():
|
|
100
|
+
return f"--- CLAUDE.md ---\n{path.read_text(encoding='utf-8', errors='replace')}"
|
|
101
|
+
return ""
|
|
102
|
+
|
|
103
|
+
def budget_bytes(self) -> int:
|
|
104
|
+
return _CLAUDE_CLI_BUDGET
|
|
105
|
+
|
|
106
|
+
def default_schema_pack(self) -> str:
|
|
107
|
+
return "coding"
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
class OpenCodeAdapter(HarnessAdapter):
|
|
111
|
+
"""Reads AGENTS.md + opencode.json from the project root."""
|
|
112
|
+
|
|
113
|
+
name = "opencode"
|
|
114
|
+
|
|
115
|
+
def read_context(self, project_root: str | Path = ".") -> str:
|
|
116
|
+
root = Path(project_root).resolve()
|
|
117
|
+
parts: list[str] = []
|
|
118
|
+
|
|
119
|
+
agents_path = self.context_file_path("AGENTS.md", project_root)
|
|
120
|
+
if agents_path.is_file():
|
|
121
|
+
parts.append(f"--- AGENTS.md ---\n{agents_path.read_text(encoding='utf-8', errors='replace')}")
|
|
122
|
+
|
|
123
|
+
oc_path = root / "opencode.json"
|
|
124
|
+
if oc_path.is_file():
|
|
125
|
+
try:
|
|
126
|
+
data = json.loads(oc_path.read_text(encoding='utf-8', errors='replace'))
|
|
127
|
+
parts.append(f"--- opencode.json ---\n{json.dumps(data, indent=2)}")
|
|
128
|
+
except (json.JSONDecodeError, OSError):
|
|
129
|
+
parts.append("--- opencode.json ---\n(invalid)")
|
|
130
|
+
|
|
131
|
+
return "\n\n".join(parts) if parts else ""
|
|
132
|
+
|
|
133
|
+
def budget_bytes(self) -> int:
|
|
134
|
+
return _OPENCODE_BUDGET
|
|
135
|
+
|
|
136
|
+
def default_schema_pack(self) -> str:
|
|
137
|
+
return "coding"
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
class OpenClawAdapter(HarnessAdapter):
|
|
141
|
+
"""Placeholder for OpenClaw (CLAUDE.md equivalent)."""
|
|
142
|
+
|
|
143
|
+
name = "openclaw"
|
|
144
|
+
|
|
145
|
+
def read_context(self, project_root: str | Path = ".") -> str:
|
|
146
|
+
path = self.context_file_path("CLAUDE.md", project_root)
|
|
147
|
+
if path.is_file():
|
|
148
|
+
return f"--- CLAUDE.md ---\n{path.read_text(encoding='utf-8', errors='replace')}"
|
|
149
|
+
return ""
|
|
150
|
+
|
|
151
|
+
def budget_bytes(self) -> int:
|
|
152
|
+
return _OPENCLAW_BUDGET
|
|
153
|
+
|
|
154
|
+
def default_schema_pack(self) -> str:
|
|
155
|
+
return "coding"
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
class OpenClaudeAdapter(HarnessAdapter):
|
|
159
|
+
"""Placeholder for OpenClaude (CLAUDE.md equivalent)."""
|
|
160
|
+
|
|
161
|
+
name = "openclaude"
|
|
162
|
+
|
|
163
|
+
def read_context(self, project_root: str | Path = ".") -> str:
|
|
164
|
+
path = self.context_file_path("CLAUDE.md", project_root)
|
|
165
|
+
if path.is_file():
|
|
166
|
+
return f"--- CLAUDE.md ---\n{path.read_text(encoding='utf-8', errors='replace')}"
|
|
167
|
+
return ""
|
|
168
|
+
|
|
169
|
+
def budget_bytes(self) -> int:
|
|
170
|
+
return _OPENCLAUDE_BUDGET
|
|
171
|
+
|
|
172
|
+
def default_schema_pack(self) -> str:
|
|
173
|
+
return "coding"
|
|
174
|
+
|
|
175
|
+
|
|
176
|
+
# ── Discovery ────────────────────────────────────────────────────────
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
def all_adapters() -> dict[str, HarnessAdapter]:
|
|
180
|
+
"""Return all adapter instances keyed by name."""
|
|
181
|
+
return {
|
|
182
|
+
"hermes": HermesAdapter(),
|
|
183
|
+
"claude_cli": ClaudeCliAdapter(),
|
|
184
|
+
"opencode": OpenCodeAdapter(),
|
|
185
|
+
"openclaw": OpenClawAdapter(),
|
|
186
|
+
"openclaude": OpenClaudeAdapter(),
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
def get_adapter(name: str, **kwargs: Any) -> HarnessAdapter:
|
|
191
|
+
"""Get a single adapter by name, raising KeyError if unknown."""
|
|
192
|
+
builders = {
|
|
193
|
+
"hermes": HermesAdapter,
|
|
194
|
+
"claude_cli": ClaudeCliAdapter,
|
|
195
|
+
"opencode": OpenCodeAdapter,
|
|
196
|
+
"openclaw": OpenClawAdapter,
|
|
197
|
+
"openclaude": OpenClaudeAdapter,
|
|
198
|
+
}
|
|
199
|
+
cls = builders.get(name)
|
|
200
|
+
if cls is None:
|
|
201
|
+
raise KeyError(f"Unknown adapter: {name}. Valid: {', '.join(sorted(builders))}")
|
|
202
|
+
return cls(**kwargs)
|