eling 0.1.0__py3-none-any.whl
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/__init__.py +37 -0
- eling/adapters/__init__.py +202 -0
- eling/brain.py +629 -0
- eling/cli.py +233 -0
- eling/compress.py +146 -0
- eling/config.py +271 -0
- eling/decay.py +63 -0
- eling/export.py +198 -0
- eling/hermes_plugin.py +65 -0
- eling/hooks.py +396 -0
- eling/layers/__init__.py +1 -0
- eling/layers/builtin.py +60 -0
- eling/layers/code.py +86 -0
- eling/layers/code_index.py +451 -0
- eling/layers/facts.py +756 -0
- eling/layers/hrr.py +119 -0
- eling/layers/kb.py +172 -0
- eling/layers/notion.py +223 -0
- eling/mcp_server.py +348 -0
- eling/permissions.py +138 -0
- eling/privacy.py +234 -0
- eling/scripts/benchmark.py +159 -0
- eling/snapshot.py +185 -0
- eling/utils/__init__.py +1 -0
- eling-0.1.0.dist-info/METADATA +102 -0
- eling-0.1.0.dist-info/RECORD +29 -0
- eling-0.1.0.dist-info/WHEEL +5 -0
- eling-0.1.0.dist-info/licenses/LICENSE +27 -0
- eling-0.1.0.dist-info/top_level.txt +1 -0
eling/__init__.py
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)
|