bikem 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.
- bikem-0.1.0/.env.example +0 -0
- bikem-0.1.0/.github/workflows/ci.yml +43 -0
- bikem-0.1.0/.gitignore +16 -0
- bikem-0.1.0/LICENSE +21 -0
- bikem-0.1.0/PKG-INFO +59 -0
- bikem-0.1.0/README.md +32 -0
- bikem-0.1.0/bikem/__init__.py +126 -0
- bikem-0.1.0/bikem/cli/__init__.py +0 -0
- bikem-0.1.0/bikem/cli/main.py +526 -0
- bikem-0.1.0/bikem/diff.py +150 -0
- bikem-0.1.0/bikem/events.py +135 -0
- bikem-0.1.0/bikem/interceptors/__init__.py +0 -0
- bikem-0.1.0/bikem/narrate.py +192 -0
- bikem-0.1.0/bikem/py.typed +0 -0
- bikem-0.1.0/bikem/recorder.py +162 -0
- bikem-0.1.0/bikem/replay.py +269 -0
- bikem-0.1.0/bikem/store.py +123 -0
- bikem-0.1.0/bikem/voice.py +253 -0
- bikem-0.1.0/examples/README.md +47 -0
- bikem-0.1.0/examples/failing_agent.py +70 -0
- bikem-0.1.0/examples/mock_agent.py +91 -0
- bikem-0.1.0/examples/real_agent.py +62 -0
- bikem-0.1.0/pyproject.toml +51 -0
- bikem-0.1.0/tests/__init__.py +0 -0
- bikem-0.1.0/tests/test_cli.py +81 -0
- bikem-0.1.0/tests/test_diff.py +66 -0
- bikem-0.1.0/tests/test_events_store.py +73 -0
- bikem-0.1.0/tests/test_narrate.py +143 -0
- bikem-0.1.0/tests/test_play.py +66 -0
- bikem-0.1.0/tests/test_recorder.py +128 -0
- bikem-0.1.0/tests/test_replay.py +173 -0
- bikem-0.1.0/tests/test_session.py +75 -0
- bikem-0.1.0/tests/test_voice.py +74 -0
bikem-0.1.0/.env.example
ADDED
|
File without changes
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
lint:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
steps:
|
|
14
|
+
- uses: actions/checkout@v4
|
|
15
|
+
- uses: astral-sh/setup-uv@v3
|
|
16
|
+
- run: uv venv
|
|
17
|
+
- run: uv pip install -e ".[dev]"
|
|
18
|
+
- run: uv run ruff check .
|
|
19
|
+
- run: uv run ruff format --check .
|
|
20
|
+
|
|
21
|
+
test:
|
|
22
|
+
runs-on: ubuntu-latest
|
|
23
|
+
strategy:
|
|
24
|
+
fail-fast: false
|
|
25
|
+
matrix:
|
|
26
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
- uses: astral-sh/setup-uv@v3
|
|
30
|
+
- run: uv venv --python ${{ matrix.python-version }}
|
|
31
|
+
- run: uv pip install -e ".[dev]"
|
|
32
|
+
- run: uv run pytest -v
|
|
33
|
+
|
|
34
|
+
build:
|
|
35
|
+
runs-on: ubuntu-latest
|
|
36
|
+
steps:
|
|
37
|
+
- uses: actions/checkout@v4
|
|
38
|
+
- uses: astral-sh/setup-uv@v3
|
|
39
|
+
- run: uv build
|
|
40
|
+
- uses: actions/upload-artifact@v4
|
|
41
|
+
with:
|
|
42
|
+
name: dist
|
|
43
|
+
path: dist/
|
bikem-0.1.0/.gitignore
ADDED
bikem-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Kelchy
|
|
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.
|
bikem-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: bikem
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Local-first memory and drift detection for long AI sessions
|
|
5
|
+
Project-URL: Homepage, https://github.com/kelchy/bikem
|
|
6
|
+
Project-URL: Repository, https://github.com/kelchy/bikem
|
|
7
|
+
Project-URL: Issues, https://github.com/kelchy/bikem/issues
|
|
8
|
+
Author: Kelchy
|
|
9
|
+
License: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: ai,context,llm,memory,observability
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Requires-Python: >=3.10
|
|
19
|
+
Requires-Dist: click>=8.1
|
|
20
|
+
Requires-Dist: httpx>=0.24
|
|
21
|
+
Requires-Dist: rich>=13.0
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest-asyncio>=0.23; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
25
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# bikem
|
|
29
|
+
|
|
30
|
+
Local-first memory and drift detection for long AI sessions.
|
|
31
|
+
|
|
32
|
+
import bikem
|
|
33
|
+
|
|
34
|
+
with bikem.session("fix-auth-bug"):
|
|
35
|
+
response = client.chat.completions.create(
|
|
36
|
+
model="gpt-4o",
|
|
37
|
+
messages=[{"role": "user", "content": "explain this stack trace"}],
|
|
38
|
+
)
|
|
39
|
+
# every call is now recorded to ~/.bikem/sessions/
|
|
40
|
+
|
|
41
|
+
Long AI sessions forget. They drift. They repeat. When something breaks at
|
|
42
|
+
step 40, you cannot reproduce it because the model is non-deterministic.
|
|
43
|
+
bikem records every LLM and tool call to a local JSONL file, reinjects the
|
|
44
|
+
right context so the session stops degrading, and flags the moment output
|
|
45
|
+
starts drifting from the original task.
|
|
46
|
+
|
|
47
|
+
No account. No network calls to us. Your traces are files on your disk.
|
|
48
|
+
|
|
49
|
+
## Install
|
|
50
|
+
|
|
51
|
+
pip install bikem
|
|
52
|
+
|
|
53
|
+
## Status
|
|
54
|
+
|
|
55
|
+
Alpha. Recorder and store are being built now.
|
|
56
|
+
|
|
57
|
+
## License
|
|
58
|
+
|
|
59
|
+
MIT
|
bikem-0.1.0/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# bikem
|
|
2
|
+
|
|
3
|
+
Local-first memory and drift detection for long AI sessions.
|
|
4
|
+
|
|
5
|
+
import bikem
|
|
6
|
+
|
|
7
|
+
with bikem.session("fix-auth-bug"):
|
|
8
|
+
response = client.chat.completions.create(
|
|
9
|
+
model="gpt-4o",
|
|
10
|
+
messages=[{"role": "user", "content": "explain this stack trace"}],
|
|
11
|
+
)
|
|
12
|
+
# every call is now recorded to ~/.bikem/sessions/
|
|
13
|
+
|
|
14
|
+
Long AI sessions forget. They drift. They repeat. When something breaks at
|
|
15
|
+
step 40, you cannot reproduce it because the model is non-deterministic.
|
|
16
|
+
bikem records every LLM and tool call to a local JSONL file, reinjects the
|
|
17
|
+
right context so the session stops degrading, and flags the moment output
|
|
18
|
+
starts drifting from the original task.
|
|
19
|
+
|
|
20
|
+
No account. No network calls to us. Your traces are files on your disk.
|
|
21
|
+
|
|
22
|
+
## Install
|
|
23
|
+
|
|
24
|
+
pip install bikem
|
|
25
|
+
|
|
26
|
+
## Status
|
|
27
|
+
|
|
28
|
+
Alpha. Recorder and store are being built now.
|
|
29
|
+
|
|
30
|
+
## License
|
|
31
|
+
|
|
32
|
+
MIT
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
"""bikem -- local-first memory and drift detection for long AI sessions.
|
|
2
|
+
|
|
3
|
+
Public API:
|
|
4
|
+
|
|
5
|
+
import bikem
|
|
6
|
+
|
|
7
|
+
with bikem.session("my-session"):
|
|
8
|
+
... # your existing code, unchanged
|
|
9
|
+
|
|
10
|
+
# or manual control:
|
|
11
|
+
with bikem.session("my-session") as s:
|
|
12
|
+
print(s.session_id)
|
|
13
|
+
print(s.trace_path)
|
|
14
|
+
|
|
15
|
+
Environment:
|
|
16
|
+
|
|
17
|
+
BIKEM_HOME storage root (default: ~/.bikem)
|
|
18
|
+
BIKEM_DISABLE set to "1" to make session() a no-op
|
|
19
|
+
"""
|
|
20
|
+
|
|
21
|
+
from __future__ import annotations
|
|
22
|
+
|
|
23
|
+
import contextlib
|
|
24
|
+
import os
|
|
25
|
+
from collections.abc import Iterator
|
|
26
|
+
from pathlib import Path
|
|
27
|
+
|
|
28
|
+
from . import recorder
|
|
29
|
+
from .events import GENESIS_HASH, EventType, compute_hash, verify_chain
|
|
30
|
+
from .replay import ReplayContext, ReplayResult, replay
|
|
31
|
+
from .store import DEFAULT_ROOT, SessionStore, list_sessions, load_session
|
|
32
|
+
|
|
33
|
+
__version__ = "0.1.0"
|
|
34
|
+
|
|
35
|
+
__all__ = [
|
|
36
|
+
"session",
|
|
37
|
+
"Session",
|
|
38
|
+
"replay",
|
|
39
|
+
"ReplayContext",
|
|
40
|
+
"ReplayResult",
|
|
41
|
+
"SessionStore",
|
|
42
|
+
"list_sessions",
|
|
43
|
+
"load_session",
|
|
44
|
+
"verify_chain",
|
|
45
|
+
"GENESIS_HASH",
|
|
46
|
+
"compute_hash",
|
|
47
|
+
"DEFAULT_ROOT",
|
|
48
|
+
"__version__",
|
|
49
|
+
]
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class Session:
|
|
53
|
+
"""A single recording session.
|
|
54
|
+
|
|
55
|
+
Returned by bikem.session(). Exposes the session id and the on-disk
|
|
56
|
+
trace path so callers can point at the file directly.
|
|
57
|
+
"""
|
|
58
|
+
|
|
59
|
+
def __init__(self, name: str = "", store: SessionStore | None = None):
|
|
60
|
+
self.name = name
|
|
61
|
+
self.store = store or SessionStore()
|
|
62
|
+
self._entered = False
|
|
63
|
+
|
|
64
|
+
@property
|
|
65
|
+
def session_id(self) -> str:
|
|
66
|
+
return self.store.session_id
|
|
67
|
+
|
|
68
|
+
@property
|
|
69
|
+
def trace_path(self) -> Path:
|
|
70
|
+
return self.store.path
|
|
71
|
+
|
|
72
|
+
def __enter__(self) -> Session:
|
|
73
|
+
self._entered = True
|
|
74
|
+
self.store.append(
|
|
75
|
+
EventType.SESSION_START,
|
|
76
|
+
{"name": self.name, "pid": os.getpid()},
|
|
77
|
+
)
|
|
78
|
+
recorder.install(self.store)
|
|
79
|
+
return self
|
|
80
|
+
|
|
81
|
+
def __exit__(self, exc_type, exc, tb) -> bool:
|
|
82
|
+
try:
|
|
83
|
+
if exc_type is None:
|
|
84
|
+
self.store.append(EventType.SESSION_END, {"status": "ok"})
|
|
85
|
+
else:
|
|
86
|
+
self.store.append(
|
|
87
|
+
EventType.SESSION_END,
|
|
88
|
+
{"status": "error", "error": f"{exc_type.__name__}: {exc}"},
|
|
89
|
+
)
|
|
90
|
+
except Exception:
|
|
91
|
+
pass
|
|
92
|
+
finally:
|
|
93
|
+
recorder.uninstall()
|
|
94
|
+
return False
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _disabled() -> bool:
|
|
98
|
+
return os.environ.get("BIKEM_DISABLE", "").strip() in ("1", "true", "yes")
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
@contextlib.contextmanager
|
|
102
|
+
def session(name: str = "", root: Path | str | None = None) -> Iterator[Session]:
|
|
103
|
+
"""Open a bikem session. Everything recorded until exit."""
|
|
104
|
+
if _disabled():
|
|
105
|
+
yield Session(name=name, store=_NullStore())
|
|
106
|
+
return
|
|
107
|
+
|
|
108
|
+
store = SessionStore(root=root)
|
|
109
|
+
sess = Session(name=name, store=store)
|
|
110
|
+
with sess:
|
|
111
|
+
yield sess
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
class _NullStore:
|
|
115
|
+
"""A store that does nothing. Used when BIKEM_DISABLE is set."""
|
|
116
|
+
|
|
117
|
+
session_id = "sess_disabled"
|
|
118
|
+
path = Path("/dev/null")
|
|
119
|
+
|
|
120
|
+
def append(self, *a, **kw):
|
|
121
|
+
from .events import Event, now_iso
|
|
122
|
+
|
|
123
|
+
return Event(seq=0, type="disabled", session_id="sess_disabled", payload={}, ts=now_iso())
|
|
124
|
+
|
|
125
|
+
def read(self):
|
|
126
|
+
return []
|
|
File without changes
|