kioku-agent-kit 0.2.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.
- kioku_agent_kit-0.2.0/.claude/settings.local.json +22 -0
- kioku_agent_kit-0.2.0/.coverage +0 -0
- kioku_agent_kit-0.2.0/.env.example +26 -0
- kioku_agent_kit-0.2.0/.github/workflows/ci.yml +63 -0
- kioku_agent_kit-0.2.0/.gitignore +35 -0
- kioku_agent_kit-0.2.0/CLAUDE.md +28 -0
- kioku_agent_kit-0.2.0/Dockerfile +30 -0
- kioku_agent_kit-0.2.0/Makefile +33 -0
- kioku_agent_kit-0.2.0/PKG-INFO +43 -0
- kioku_agent_kit-0.2.0/README.md +214 -0
- kioku_agent_kit-0.2.0/docker-compose.full.yml +55 -0
- kioku_agent_kit-0.2.0/docker-compose.minimal.yml +30 -0
- kioku_agent_kit-0.2.0/docker-compose.yml +31 -0
- kioku_agent_kit-0.2.0/docs/01-requirements.md +52 -0
- kioku_agent_kit-0.2.0/docs/02-system-design.md +167 -0
- kioku_agent_kit-0.2.0/docs/03-implementation-plan.md +181 -0
- kioku_agent_kit-0.2.0/docs/05-identity-mapping.md +67 -0
- kioku_agent_kit-0.2.0/docs/06-restructure-plan.md +323 -0
- kioku_agent_kit-0.2.0/docs/07-phase7-plan.md +88 -0
- kioku_agent_kit-0.2.0/docs/DEVLOG-phase7.md +103 -0
- kioku_agent_kit-0.2.0/docs/DEVLOG-phase8.md +118 -0
- kioku_agent_kit-0.2.0/docs/DEVLOG-restructure.md +143 -0
- kioku_agent_kit-0.2.0/docs/DEVLOG.md +111 -0
- kioku_agent_kit-0.2.0/docs/ISSUES.md +36 -0
- kioku_agent_kit-0.2.0/docs/architecture/benchmark-2026-02-25.md +254 -0
- kioku_agent_kit-0.2.0/docs/architecture/evaluation.md +197 -0
- kioku_agent_kit-0.2.0/docs/architecture/save.md +126 -0
- kioku_agent_kit-0.2.0/docs/architecture/search.md +162 -0
- kioku_agent_kit-0.2.0/docs/architecture/system.md +184 -0
- kioku_agent_kit-0.2.0/phucnt_telegram_kioku_backup/2026-02-24.md +529 -0
- kioku_agent_kit-0.2.0/phucnt_telegram_kioku_backup/2026-02-25.md +2105 -0
- kioku_agent_kit-0.2.0/phucnt_telegram_kioku_backup/README.md +34 -0
- kioku_agent_kit-0.2.0/phucnt_telegram_kioku_backup/memory_pre_phase7/2026-02-22.md +205 -0
- kioku_agent_kit-0.2.0/phucnt_telegram_kioku_backup/memory_pre_phase7/2026-02-23.md +351 -0
- kioku_agent_kit-0.2.0/phucnt_telegram_kioku_backup/restore.py +112 -0
- kioku_agent_kit-0.2.0/phucnt_telegram_kioku_backup/restore_today.py +51 -0
- kioku_agent_kit-0.2.0/pyproject.toml +66 -0
- kioku_agent_kit-0.2.0/scripts/clean_test_data.py +95 -0
- kioku_agent_kit-0.2.0/scripts/docker-entrypoint.sh +66 -0
- kioku_agent_kit-0.2.0/scripts/migrate_tenant.py +74 -0
- kioku_agent_kit-0.2.0/scripts/setup.sh +171 -0
- kioku_agent_kit-0.2.0/skills/kioku/SKILL.md +216 -0
- kioku_agent_kit-0.2.0/src/kioku/__init__.py +1 -0
- kioku_agent_kit-0.2.0/src/kioku/cli.py +271 -0
- kioku_agent_kit-0.2.0/src/kioku/config.py +93 -0
- kioku_agent_kit-0.2.0/src/kioku/pipeline/__init__.py +0 -0
- kioku_agent_kit-0.2.0/src/kioku/pipeline/embedder.py +64 -0
- kioku_agent_kit-0.2.0/src/kioku/pipeline/extractor.py +278 -0
- kioku_agent_kit-0.2.0/src/kioku/pipeline/graph_writer.py +499 -0
- kioku_agent_kit-0.2.0/src/kioku/pipeline/keyword_writer.py +266 -0
- kioku_agent_kit-0.2.0/src/kioku/pipeline/vector_writer.py +138 -0
- kioku_agent_kit-0.2.0/src/kioku/resources/CLAUDE.agent.md +137 -0
- kioku_agent_kit-0.2.0/src/kioku/resources/SKILL.md +216 -0
- kioku_agent_kit-0.2.0/src/kioku/resources/__init__.py +0 -0
- kioku_agent_kit-0.2.0/src/kioku/resources/docker-compose.yml +31 -0
- kioku_agent_kit-0.2.0/src/kioku/search/__init__.py +0 -0
- kioku_agent_kit-0.2.0/src/kioku/search/bm25.py +56 -0
- kioku_agent_kit-0.2.0/src/kioku/search/graph.py +94 -0
- kioku_agent_kit-0.2.0/src/kioku/search/reranker.py +46 -0
- kioku_agent_kit-0.2.0/src/kioku/search/semantic.py +35 -0
- kioku_agent_kit-0.2.0/src/kioku/server.py +142 -0
- kioku_agent_kit-0.2.0/src/kioku/service.py +694 -0
- kioku_agent_kit-0.2.0/src/kioku/storage/__init__.py +0 -0
- kioku_agent_kit-0.2.0/src/kioku/storage/markdown.py +140 -0
- kioku_agent_kit-0.2.0/src/kioku/tools/__init__.py +0 -0
- kioku_agent_kit-0.2.0/templates/CLAUDE.agent.md +137 -0
- kioku_agent_kit-0.2.0/tests/README.md +52 -0
- kioku_agent_kit-0.2.0/tests/__init__.py +0 -0
- kioku_agent_kit-0.2.0/tests/benchmark_after.json +343 -0
- kioku_agent_kit-0.2.0/tests/benchmark_after_entity_fix.json +417 -0
- kioku_agent_kit-0.2.0/tests/benchmark_after_entity_fix_v2.json +433 -0
- kioku_agent_kit-0.2.0/tests/benchmark_after_reingest.json +335 -0
- kioku_agent_kit-0.2.0/tests/benchmark_before.json +340 -0
- kioku_agent_kit-0.2.0/tests/benchmark_search.py +335 -0
- kioku_agent_kit-0.2.0/tests/e2e_cli.py +154 -0
- kioku_agent_kit-0.2.0/tests/e2e_mcp_client.py +175 -0
- kioku_agent_kit-0.2.0/tests/test_bm25.py +87 -0
- kioku_agent_kit-0.2.0/tests/test_graph.py +151 -0
- kioku_agent_kit-0.2.0/tests/test_reranker.py +50 -0
- kioku_agent_kit-0.2.0/tests/test_server.py +263 -0
- kioku_agent_kit-0.2.0/tests/test_storage.py +66 -0
- kioku_agent_kit-0.2.0/tests/test_vector.py +103 -0
- kioku_agent_kit-0.2.0/update_sqlite.py +13 -0
- kioku_agent_kit-0.2.0/uv.lock +2842 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"permissions": {
|
|
3
|
+
"allow": [
|
|
4
|
+
"Bash(uv *)",
|
|
5
|
+
"Bash(make *)",
|
|
6
|
+
"Bash(python *)",
|
|
7
|
+
"Bash(export *)",
|
|
8
|
+
"Bash(kioku *)",
|
|
9
|
+
"Bash(ls *)",
|
|
10
|
+
"Bash(which *)",
|
|
11
|
+
"Bash(cat *)",
|
|
12
|
+
"Bash(uv run:*)",
|
|
13
|
+
"Bash",
|
|
14
|
+
"Bash(uv build:*)",
|
|
15
|
+
"Bash(chmod:*)",
|
|
16
|
+
"Bash(docker build:*)",
|
|
17
|
+
"Bash(docker images:*)",
|
|
18
|
+
"Bash(docker run:*)",
|
|
19
|
+
"Bash(git status:*)"
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# === Kioku Configuration ===
|
|
2
|
+
# Copy this file to .env and fill in values
|
|
3
|
+
|
|
4
|
+
# User context (multi-tenant isolation)
|
|
5
|
+
# KIOKU_USER_ID=default
|
|
6
|
+
|
|
7
|
+
# Paths
|
|
8
|
+
KIOKU_MEMORY_DIR=~/.kioku/memory
|
|
9
|
+
KIOKU_DATA_DIR=~/.kioku/data
|
|
10
|
+
|
|
11
|
+
# ChromaDB
|
|
12
|
+
# KIOKU_CHROMA_MODE=auto # auto | server | embedded
|
|
13
|
+
KIOKU_CHROMA_HOST=localhost
|
|
14
|
+
KIOKU_CHROMA_PORT=8000
|
|
15
|
+
# KIOKU_CHROMA_PERSIST_DIR= # default: ~/.kioku/data/chroma (embedded mode)
|
|
16
|
+
|
|
17
|
+
# FalkorDB (Knowledge Graph)
|
|
18
|
+
KIOKU_FALKORDB_HOST=localhost
|
|
19
|
+
KIOKU_FALKORDB_PORT=6379
|
|
20
|
+
|
|
21
|
+
# Ollama (Embeddings)
|
|
22
|
+
KIOKU_OLLAMA_HOST=http://localhost:11434
|
|
23
|
+
KIOKU_OLLAMA_MODEL=nomic-embed-text
|
|
24
|
+
|
|
25
|
+
# LLM (Entity Extraction)
|
|
26
|
+
KIOKU_ANTHROPIC_API_KEY=
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
15
|
+
extras: ["cli", "mcp", "full"]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Install uv
|
|
21
|
+
uses: astral-sh/setup-uv@v4
|
|
22
|
+
|
|
23
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
24
|
+
run: uv python install ${{ matrix.python-version }}
|
|
25
|
+
|
|
26
|
+
- name: Install dependencies
|
|
27
|
+
run: uv sync --extra ${{ matrix.extras }} --extra dev
|
|
28
|
+
|
|
29
|
+
- name: Lint
|
|
30
|
+
if: matrix.extras == 'full' && matrix.python-version == '3.12'
|
|
31
|
+
run: |
|
|
32
|
+
uv run ruff check src/ tests/
|
|
33
|
+
uv run ruff format --check src/ tests/
|
|
34
|
+
|
|
35
|
+
- name: Run integration tests
|
|
36
|
+
if: matrix.extras == 'full'
|
|
37
|
+
run: uv run python -m pytest tests/test_server.py -v
|
|
38
|
+
|
|
39
|
+
- name: Verify CLI import
|
|
40
|
+
if: matrix.extras == 'cli' || matrix.extras == 'full'
|
|
41
|
+
run: uv run kioku --help
|
|
42
|
+
|
|
43
|
+
- name: Verify MCP import
|
|
44
|
+
if: matrix.extras == 'mcp' || matrix.extras == 'full'
|
|
45
|
+
run: uv run python -c "from kioku.server import mcp; print(f'MCP server: {mcp.name}')"
|
|
46
|
+
|
|
47
|
+
build:
|
|
48
|
+
runs-on: ubuntu-latest
|
|
49
|
+
needs: test
|
|
50
|
+
steps:
|
|
51
|
+
- uses: actions/checkout@v4
|
|
52
|
+
|
|
53
|
+
- name: Install uv
|
|
54
|
+
uses: astral-sh/setup-uv@v4
|
|
55
|
+
|
|
56
|
+
- name: Build wheel
|
|
57
|
+
run: uv build
|
|
58
|
+
|
|
59
|
+
- name: Upload artifacts
|
|
60
|
+
uses: actions/upload-artifact@v4
|
|
61
|
+
with:
|
|
62
|
+
name: dist
|
|
63
|
+
path: dist/
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.egg-info/
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
.eggs/
|
|
9
|
+
|
|
10
|
+
# Virtual environment
|
|
11
|
+
.venv/
|
|
12
|
+
venv/
|
|
13
|
+
|
|
14
|
+
# IDE
|
|
15
|
+
.vscode/
|
|
16
|
+
.idea/
|
|
17
|
+
*.swp
|
|
18
|
+
*.swo
|
|
19
|
+
|
|
20
|
+
# Environment
|
|
21
|
+
.env
|
|
22
|
+
|
|
23
|
+
# Data (local only)
|
|
24
|
+
*.db
|
|
25
|
+
data/
|
|
26
|
+
|
|
27
|
+
# OS
|
|
28
|
+
.DS_Store
|
|
29
|
+
Thumbs.db
|
|
30
|
+
|
|
31
|
+
# Pytest
|
|
32
|
+
.pytest_cache/
|
|
33
|
+
|
|
34
|
+
# Ruff
|
|
35
|
+
.ruff_cache/
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Kioku MCP — Claude Assistant Guide
|
|
2
|
+
|
|
3
|
+
You are Claude Code, an AI agent working on the Kioku MCP server project. Your goal is to help implement feature restructuring and maintain code quality based on the requirements defined in the `docs` directory.
|
|
4
|
+
|
|
5
|
+
## Current Primary Task: Refactoring & CLI Support
|
|
6
|
+
The user might ask you to implement the phases outlined in `docs/06-restructure-plan.md`.
|
|
7
|
+
**CRITICAL:**
|
|
8
|
+
1. **Always read `docs/06-restructure-plan.md`** first to understand the Phase and objective you are working on.
|
|
9
|
+
2. Read `src/kioku/server.py` — this file currently contains ALL business logic, FastMCP decorators, and tool coordination, and needs to be carefully refactored without breaking any functionality.
|
|
10
|
+
3. Be aware that the project uses 6 core tools: `save_memory`, `search_memories`, `recall_related`, `explain_connection`, `get_timeline`, and `list_memory_dates` (Note: `get_memories_by_date` and `get_life_patterns` were recently removed to adhere to the Minimalist architecture).
|
|
11
|
+
|
|
12
|
+
## Codebase Context
|
|
13
|
+
- Read `docs/01-requirements.md` and `docs/02-system-design.md` for architectural context.
|
|
14
|
+
- We use a **Minimalist RAG Architecture**: `SQLite FTS5` for BM25, `ChromaDB` for Vector Search, and `FalkorDB` for GraphDB Traversal.
|
|
15
|
+
- Python 3.12 / 3.13 is used.
|
|
16
|
+
- Dependencies are managed by `uv`. Use `uv add` to add packages.
|
|
17
|
+
|
|
18
|
+
## Testing Strategy
|
|
19
|
+
1. **Integration Tests (`tests/`)**: Run `make test` to execute fast integration tests using mocks (FakeEmbedder, InMemoryGraphStore). Tests must maintain 100% pass rate.
|
|
20
|
+
2. **End-to-End Tests**: Run `export $(grep -v '^#' .env | xargs) && python tests/e2e_mcp_client.py`. This acts as a real MCP Client via stdio, executing all 6 tools, 2 resources, and 3 prompts against real Live DBs and Anthropic API. Ensure it passes without errors when logic is changed.
|
|
21
|
+
- **⚠️ CRITICAL DATA WARNING:** When running E2E tests, ensure that you use a separate mock user or mock tenant. **DO NOT** modify, pollute, or overwrite the real Telegram user's data (e.g., `~/.kioku/users/telegram/` or their sessions in `~/.openclaw`). All test data must be completely isolated.
|
|
22
|
+
|
|
23
|
+
## Guidelines
|
|
24
|
+
- Write strict type hints (`-> dict`, `-> list`, etc.).
|
|
25
|
+
- Update integration tests in `/tests/` when modifying logic. Use `make test` to ensure 100% test pass.
|
|
26
|
+
- **Graceful degradation is a must:** Missing databases (ChromaDB, FalkorDB) or missing LLM parameters should gracefully fallback (e.g., FakeEmbedder, InMemoryGraphStore) and never crash the CLI/MCP app.
|
|
27
|
+
- Never write duplicate code logic. A `KiokuService` class should become the single source of truth for both MCP interfaces and future CLI interfaces.
|
|
28
|
+
- Any modifications to terminal output logic for CLI should display properly in Vietnamese (`ensure_ascii=False` when printing JSON).
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
FROM python:3.12-slim
|
|
2
|
+
|
|
3
|
+
WORKDIR /app
|
|
4
|
+
|
|
5
|
+
# Install system deps
|
|
6
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
7
|
+
gcc \
|
|
8
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
9
|
+
|
|
10
|
+
# Copy project files
|
|
11
|
+
COPY pyproject.toml .
|
|
12
|
+
COPY src/ src/
|
|
13
|
+
|
|
14
|
+
# Install kioku with all extras
|
|
15
|
+
RUN pip install --no-cache-dir ".[full]"
|
|
16
|
+
|
|
17
|
+
# Create data directories
|
|
18
|
+
RUN mkdir -p /data/memory /data/data
|
|
19
|
+
|
|
20
|
+
ENV KIOKU_MEMORY_DIR=/data/memory \
|
|
21
|
+
KIOKU_DATA_DIR=/data/data \
|
|
22
|
+
KIOKU_CHROMA_MODE=auto
|
|
23
|
+
|
|
24
|
+
COPY scripts/docker-entrypoint.sh /docker-entrypoint.sh
|
|
25
|
+
RUN chmod +x /docker-entrypoint.sh
|
|
26
|
+
|
|
27
|
+
ENTRYPOINT ["/docker-entrypoint.sh"]
|
|
28
|
+
|
|
29
|
+
# Default: run MCP server via stdio
|
|
30
|
+
CMD ["mcp"]
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
.PHONY: install dev test lint run clean
|
|
2
|
+
|
|
3
|
+
install:
|
|
4
|
+
pip install -e ".[dev]"
|
|
5
|
+
|
|
6
|
+
install-all:
|
|
7
|
+
pip install -e ".[all,dev]"
|
|
8
|
+
|
|
9
|
+
dev:
|
|
10
|
+
python -m src.kioku.server
|
|
11
|
+
|
|
12
|
+
test:
|
|
13
|
+
python -m pytest tests/ -v
|
|
14
|
+
|
|
15
|
+
test-watch:
|
|
16
|
+
python -m pytest tests/ -v --tb=short -x
|
|
17
|
+
|
|
18
|
+
lint:
|
|
19
|
+
ruff check src/ tests/
|
|
20
|
+
ruff format --check src/ tests/
|
|
21
|
+
|
|
22
|
+
format:
|
|
23
|
+
ruff format src/ tests/
|
|
24
|
+
|
|
25
|
+
docker-up:
|
|
26
|
+
docker compose up -d
|
|
27
|
+
|
|
28
|
+
docker-down:
|
|
29
|
+
docker compose down
|
|
30
|
+
|
|
31
|
+
clean:
|
|
32
|
+
rm -rf .pytest_cache __pycache__ src/**/__pycache__
|
|
33
|
+
find . -name "*.pyc" -delete
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: kioku-agent-kit
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Personal memory engine for AI agents — tri-hybrid search (BM25 + Vector + KG), CLI & MCP interfaces
|
|
5
|
+
Project-URL: Homepage, https://github.com/phuc-nt/kioku-agent-kit
|
|
6
|
+
Project-URL: Repository, https://github.com/phuc-nt/kioku-agent-kit
|
|
7
|
+
Project-URL: Issues, https://github.com/phuc-nt/kioku-agent-kit/issues
|
|
8
|
+
Author-email: Phúc Nguyễn <phucnt@example.com>
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
Keywords: agent,ai,claude,knowledge-graph,mcp,memory,rag
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
19
|
+
Requires-Python: >=3.11
|
|
20
|
+
Requires-Dist: pydantic-settings>=2.0
|
|
21
|
+
Requires-Dist: pydantic>=2.0
|
|
22
|
+
Requires-Dist: python-dotenv>=1.0
|
|
23
|
+
Provides-Extra: cli
|
|
24
|
+
Requires-Dist: typer>=0.24.1; extra == 'cli'
|
|
25
|
+
Provides-Extra: dev
|
|
26
|
+
Requires-Dist: pytest-asyncio>=0.24; extra == 'dev'
|
|
27
|
+
Requires-Dist: pytest>=8.0; extra == 'dev'
|
|
28
|
+
Requires-Dist: ruff>=0.8; extra == 'dev'
|
|
29
|
+
Provides-Extra: full
|
|
30
|
+
Requires-Dist: anthropic>=0.40; extra == 'full'
|
|
31
|
+
Requires-Dist: chromadb>=0.6; extra == 'full'
|
|
32
|
+
Requires-Dist: falkordb>=1.0; extra == 'full'
|
|
33
|
+
Requires-Dist: fastmcp>=2.0.0; extra == 'full'
|
|
34
|
+
Requires-Dist: ollama>=0.4; extra == 'full'
|
|
35
|
+
Requires-Dist: typer>=0.24.1; extra == 'full'
|
|
36
|
+
Provides-Extra: graph
|
|
37
|
+
Requires-Dist: anthropic>=0.40; extra == 'graph'
|
|
38
|
+
Requires-Dist: falkordb>=1.0; extra == 'graph'
|
|
39
|
+
Provides-Extra: mcp
|
|
40
|
+
Requires-Dist: fastmcp>=2.0.0; extra == 'mcp'
|
|
41
|
+
Provides-Extra: vector
|
|
42
|
+
Requires-Dist: chromadb>=0.6; extra == 'vector'
|
|
43
|
+
Requires-Dist: ollama>=0.4; extra == 'vector'
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
# Kioku Agent Kit
|
|
2
|
+
|
|
3
|
+
**Kioku** (記憶 — *memory*) is a personal memory engine for AI agents. Save any thought, event, or feeling — Kioku stores it, understands context, and retrieves it via **tri-hybrid search** (BM25 + semantic vector + knowledge graph).
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
You → "Went to coffee with Mai, discussed the AI project"
|
|
7
|
+
Kioku → saves to markdown + indexes BM25 + vector + knowledge graph
|
|
8
|
+
You → "Who is Mai?" or "What did I discuss last week?"
|
|
9
|
+
Kioku → traverses the graph, finds connections, returns evidence
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Designed to be used by AI agents (OpenClaw, Claude Code, Cursor, etc.) as a long-term memory CLI tool — or as an MCP server for Claude Desktop.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Quick Start
|
|
17
|
+
|
|
18
|
+
### Option 1: CLI only (fastest, BM25 only)
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install kioku-agent-kit[cli]
|
|
22
|
+
kioku save "First memory — testing Kioku" --mood happy --tags test
|
|
23
|
+
kioku search "test"
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
### Option 2: Full stack with Docker (recommended)
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
git clone https://github.com/phuc-nt/kioku-agent-kit.git && cd kioku-agent-kit
|
|
30
|
+
cp .env.example .env # add KIOKU_ANTHROPIC_API_KEY
|
|
31
|
+
|
|
32
|
+
# Start databases (ChromaDB + FalkorDB + Ollama)
|
|
33
|
+
docker compose up -d
|
|
34
|
+
|
|
35
|
+
# Install with all features
|
|
36
|
+
pip install -e ".[full]"
|
|
37
|
+
|
|
38
|
+
# Test
|
|
39
|
+
kioku save "Hello Kioku" --mood happy
|
|
40
|
+
kioku search "hello"
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Option 3: MCP Server (for Claude Desktop / Cursor)
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
pip install kioku-agent-kit[mcp,vector,graph]
|
|
47
|
+
python -m kioku.server
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Add to `claude_desktop_config.json`:
|
|
51
|
+
```json
|
|
52
|
+
{
|
|
53
|
+
"mcpServers": {
|
|
54
|
+
"kioku": {
|
|
55
|
+
"command": "python",
|
|
56
|
+
"args": ["-m", "kioku.server"],
|
|
57
|
+
"env": { "KIOKU_USER_ID": "myproject" }
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Option 4: Claude Code / Cursor (CLI agent mode)
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
pip install kioku-agent-kit[full]
|
|
67
|
+
docker compose up -d
|
|
68
|
+
export KIOKU_USER_ID=myproject
|
|
69
|
+
export KIOKU_ANTHROPIC_API_KEY=sk-ant-...
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Copy `skills/kioku/SKILL.md` to your project's skills directory — Claude Code will automatically discover and use Kioku for memory operations.
|
|
73
|
+
|
|
74
|
+
---
|
|
75
|
+
|
|
76
|
+
## Install Options
|
|
77
|
+
|
|
78
|
+
| Command | What you get |
|
|
79
|
+
|---|---|
|
|
80
|
+
| `pip install kioku-agent-kit[cli]` | CLI + BM25 keyword search |
|
|
81
|
+
| `pip install kioku-agent-kit[cli,vector]` | + semantic search (ChromaDB + Ollama) |
|
|
82
|
+
| `pip install kioku-agent-kit[mcp]` | MCP server only |
|
|
83
|
+
| `pip install kioku-agent-kit[full]` | Everything: CLI + MCP + vector + graph |
|
|
84
|
+
|
|
85
|
+
---
|
|
86
|
+
|
|
87
|
+
## CLI Commands
|
|
88
|
+
|
|
89
|
+
| Command | Description | Example |
|
|
90
|
+
|---|---|---|
|
|
91
|
+
| `kioku save TEXT` | Save a memory | `kioku save "Lunch with Mai" --mood happy --tags food,friend` |
|
|
92
|
+
| `kioku search QUERY` | Unified search (BM25 + vector + graph) | `kioku search "Mai AI project" --limit 10` |
|
|
93
|
+
| `kioku entities` | Browse entity vocabulary | `kioku entities --limit 50` |
|
|
94
|
+
| `kioku timeline` | Chronological entries | `kioku timeline --from 2026-02-01 --to 2026-02-28` |
|
|
95
|
+
|
|
96
|
+
`search` automatically extracts entities from the query using LLM + canonical entity vocabulary. Pass `--entities "X,Y"` to override.
|
|
97
|
+
|
|
98
|
+
**Environment:**
|
|
99
|
+
```bash
|
|
100
|
+
KIOKU_USER_ID=myproject # data isolation key (default: default)
|
|
101
|
+
KIOKU_ANTHROPIC_API_KEY=sk-ant- # for entity extraction (optional — degrades gracefully)
|
|
102
|
+
KIOKU_OLLAMA_MODEL=bge-m3 # embedding model (default: bge-m3)
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
## Architecture
|
|
108
|
+
|
|
109
|
+
```
|
|
110
|
+
┌─────────────────────────────────────────────────────────┐
|
|
111
|
+
│ Interface Layer │
|
|
112
|
+
│ │
|
|
113
|
+
│ server.py (MCP) cli.py (Typer CLI) │
|
|
114
|
+
│ @mcp.tool() @app.command() │
|
|
115
|
+
│ │ │ │
|
|
116
|
+
│ └───────────┬─────────────┘ │
|
|
117
|
+
│ ▼ │
|
|
118
|
+
│ service.py (KiokuService) │
|
|
119
|
+
│ │ │
|
|
120
|
+
│ ┌────────────┼────────────┐ │
|
|
121
|
+
│ ▼ ▼ ▼ │
|
|
122
|
+
│ pipeline/ search/ storage/ │
|
|
123
|
+
│ (indexing) (retrieval) (markdown) │
|
|
124
|
+
│ │ │ │ │
|
|
125
|
+
│ ▼ ▼ ▼ │
|
|
126
|
+
│ ChromaDB FalkorDB SQLite FTS5 │
|
|
127
|
+
│ (vector) (graph) (keyword) │
|
|
128
|
+
└─────────────────────────────────────────────────────────┘
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Search pipeline:** BM25 + Vector + Graph → RRF rerank → Graph context enrichment → Results with evidence
|
|
132
|
+
|
|
133
|
+
**Save pipeline:** Markdown → SQLite FTS5 → ChromaDB embedding → FalkorDB entity/relationship graph
|
|
134
|
+
|
|
135
|
+
---
|
|
136
|
+
|
|
137
|
+
## MCP Interface (for Claude Desktop)
|
|
138
|
+
|
|
139
|
+
**4 Tools:** `save_memory`, `search_memories`, `list_entities`, `get_timeline`
|
|
140
|
+
|
|
141
|
+
**2 Resources:** `kioku://memories/{date}`, `kioku://entities/{entity}`
|
|
142
|
+
|
|
143
|
+
**3 Prompts:** `reflect_on_day`, `analyze_relationships`, `weekly_review`
|
|
144
|
+
|
|
145
|
+
---
|
|
146
|
+
|
|
147
|
+
## Docker
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# Full: Kioku + ChromaDB + FalkorDB + Ollama
|
|
151
|
+
docker compose up -d
|
|
152
|
+
|
|
153
|
+
# Minimal: no graph DB
|
|
154
|
+
docker compose -f docker-compose.minimal.yml up -d
|
|
155
|
+
|
|
156
|
+
# Use CLI inside container
|
|
157
|
+
docker compose exec kioku kioku search "test"
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Graceful Degradation
|
|
163
|
+
|
|
164
|
+
| Missing | Fallback |
|
|
165
|
+
|---|---|
|
|
166
|
+
| Ollama / ChromaDB | Fake embeddings (BM25 still works) |
|
|
167
|
+
| FalkorDB | InMemoryGraphStore (search still works) |
|
|
168
|
+
| Anthropic API key | No auto entity extraction (pass `--entities` manually) |
|
|
169
|
+
|
|
170
|
+
Kioku never crashes on missing infrastructure — it just skips the unavailable component.
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## Tech Stack
|
|
175
|
+
|
|
176
|
+
| Component | Technology |
|
|
177
|
+
|---|---|
|
|
178
|
+
| Core | Python 3.12+ / Pydantic |
|
|
179
|
+
| CLI | Typer |
|
|
180
|
+
| MCP Server | FastMCP |
|
|
181
|
+
| Vector DB | ChromaDB |
|
|
182
|
+
| Graph DB | FalkorDB |
|
|
183
|
+
| Keyword Index | SQLite FTS5 |
|
|
184
|
+
| Embedding | Ollama (`bge-m3`) |
|
|
185
|
+
| Entity Extraction | Claude Haiku 4.5 (Anthropic API) |
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## Development
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
git clone https://github.com/phuc-nt/kioku-agent-kit.git && cd kioku-agent-kit
|
|
193
|
+
pip install -e ".[full,dev]"
|
|
194
|
+
docker compose up -d
|
|
195
|
+
|
|
196
|
+
uv run pytest tests/ -v # unit tests (mocked DBs)
|
|
197
|
+
python tests/e2e_mcp_client.py # MCP E2E (real DBs)
|
|
198
|
+
python tests/e2e_cli.py # CLI E2E (real DBs)
|
|
199
|
+
make lint # ruff check + format
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
---
|
|
203
|
+
|
|
204
|
+
## Docs
|
|
205
|
+
|
|
206
|
+
- [System Architecture](docs/architecture/system.md)
|
|
207
|
+
- [Search Architecture](docs/architecture/search.md)
|
|
208
|
+
- [Save Architecture](docs/architecture/save.md)
|
|
209
|
+
|
|
210
|
+
---
|
|
211
|
+
|
|
212
|
+
## License
|
|
213
|
+
|
|
214
|
+
MIT
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Kioku Full Stack — Kioku + ChromaDB server + FalkorDB + Ollama
|
|
2
|
+
# All features enabled: BM25 + Vector Search + Knowledge Graph
|
|
3
|
+
#
|
|
4
|
+
# Usage: docker compose -f docker-compose.full.yml up -d
|
|
5
|
+
|
|
6
|
+
services:
|
|
7
|
+
kioku:
|
|
8
|
+
build: .
|
|
9
|
+
volumes:
|
|
10
|
+
- kioku_data:/data
|
|
11
|
+
environment:
|
|
12
|
+
- KIOKU_CHROMA_MODE=server
|
|
13
|
+
- KIOKU_CHROMA_HOST=chromadb
|
|
14
|
+
- KIOKU_CHROMA_PORT=8000
|
|
15
|
+
- KIOKU_FALKORDB_HOST=falkordb
|
|
16
|
+
- KIOKU_FALKORDB_PORT=6379
|
|
17
|
+
- KIOKU_OLLAMA_HOST=http://ollama:11434
|
|
18
|
+
- KIOKU_OLLAMA_MODEL=nomic-embed-text
|
|
19
|
+
- KIOKU_ANTHROPIC_API_KEY=${KIOKU_ANTHROPIC_API_KEY:-}
|
|
20
|
+
depends_on:
|
|
21
|
+
- chromadb
|
|
22
|
+
- falkordb
|
|
23
|
+
- ollama
|
|
24
|
+
|
|
25
|
+
chromadb:
|
|
26
|
+
image: chromadb/chroma:latest
|
|
27
|
+
ports:
|
|
28
|
+
- "8000:8000"
|
|
29
|
+
volumes:
|
|
30
|
+
- chroma_data:/chroma/chroma
|
|
31
|
+
environment:
|
|
32
|
+
- ANONYMIZED_TELEMETRY=false
|
|
33
|
+
restart: unless-stopped
|
|
34
|
+
|
|
35
|
+
falkordb:
|
|
36
|
+
image: falkordb/falkordb:latest
|
|
37
|
+
ports:
|
|
38
|
+
- "6379:6379"
|
|
39
|
+
volumes:
|
|
40
|
+
- falkordb_data:/data
|
|
41
|
+
restart: unless-stopped
|
|
42
|
+
|
|
43
|
+
ollama:
|
|
44
|
+
image: ollama/ollama:latest
|
|
45
|
+
ports:
|
|
46
|
+
- "11434:11434"
|
|
47
|
+
volumes:
|
|
48
|
+
- ollama_data:/root/.ollama
|
|
49
|
+
restart: unless-stopped
|
|
50
|
+
|
|
51
|
+
volumes:
|
|
52
|
+
kioku_data:
|
|
53
|
+
chroma_data:
|
|
54
|
+
falkordb_data:
|
|
55
|
+
ollama_data:
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Kioku Minimal Stack — Kioku + Ollama only
|
|
2
|
+
# ChromaDB runs in embedded mode, no FalkorDB (graph features disabled)
|
|
3
|
+
#
|
|
4
|
+
# Usage: docker compose -f docker-compose.minimal.yml up -d
|
|
5
|
+
|
|
6
|
+
services:
|
|
7
|
+
kioku:
|
|
8
|
+
build: .
|
|
9
|
+
volumes:
|
|
10
|
+
- kioku_data:/data
|
|
11
|
+
environment:
|
|
12
|
+
- KIOKU_CHROMA_MODE=embedded
|
|
13
|
+
- KIOKU_OLLAMA_HOST=http://ollama:11434
|
|
14
|
+
- KIOKU_OLLAMA_MODEL=nomic-embed-text
|
|
15
|
+
depends_on:
|
|
16
|
+
- ollama
|
|
17
|
+
# Default CMD is "mcp" — override for CLI:
|
|
18
|
+
# docker compose -f docker-compose.minimal.yml exec kioku kioku search "test"
|
|
19
|
+
|
|
20
|
+
ollama:
|
|
21
|
+
image: ollama/ollama:latest
|
|
22
|
+
ports:
|
|
23
|
+
- "11434:11434"
|
|
24
|
+
volumes:
|
|
25
|
+
- ollama_data:/root/.ollama
|
|
26
|
+
restart: unless-stopped
|
|
27
|
+
|
|
28
|
+
volumes:
|
|
29
|
+
kioku_data:
|
|
30
|
+
ollama_data:
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
services:
|
|
2
|
+
falkordb:
|
|
3
|
+
image: falkordb/falkordb:latest
|
|
4
|
+
ports:
|
|
5
|
+
- "6379:6379"
|
|
6
|
+
volumes:
|
|
7
|
+
- falkordb_data:/data
|
|
8
|
+
restart: unless-stopped
|
|
9
|
+
|
|
10
|
+
chromadb:
|
|
11
|
+
image: chromadb/chroma:latest
|
|
12
|
+
ports:
|
|
13
|
+
- "8000:8000"
|
|
14
|
+
volumes:
|
|
15
|
+
- chroma_data:/chroma/chroma
|
|
16
|
+
environment:
|
|
17
|
+
- ANONYMIZED_TELEMETRY=false
|
|
18
|
+
restart: unless-stopped
|
|
19
|
+
|
|
20
|
+
ollama:
|
|
21
|
+
image: ollama/ollama:latest
|
|
22
|
+
ports:
|
|
23
|
+
- "11434:11434"
|
|
24
|
+
volumes:
|
|
25
|
+
- ollama_data:/root/.ollama
|
|
26
|
+
restart: unless-stopped
|
|
27
|
+
|
|
28
|
+
volumes:
|
|
29
|
+
falkordb_data:
|
|
30
|
+
chroma_data:
|
|
31
|
+
ollama_data:
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# Kioku MCP Server — Requirements
|
|
2
|
+
|
|
3
|
+
## Mục tiêu
|
|
4
|
+
|
|
5
|
+
Kioku là một MCP Server đóng vai trợ lý lưu trữ ký ức cá nhân (diary/lifelog). Người dùng nhắn bất kỳ suy nghĩ, sự kiện, cảm xúc nào → Kioku lưu trữ, hiểu ngữ nghĩa, và có thể truy vấn lại theo **ý nghĩa sâu** — giúp người dùng lý giải bản thân và không bao giờ quên các ký ức quan trọng.
|
|
6
|
+
|
|
7
|
+
## Functional Requirements
|
|
8
|
+
|
|
9
|
+
### FR1 — Lưu trữ ký ức (Save)
|
|
10
|
+
- Nhận đầu vào là text tự do (không cần format)
|
|
11
|
+
- Tự động gắn timestamp, extract entities (người, nơi chốn, cảm xúc, sự kiện)
|
|
12
|
+
- Lưu raw text vào Markdown file (source of truth)
|
|
13
|
+
- Index song song vào Vector DB, Graph DB, Keyword Index
|
|
14
|
+
|
|
15
|
+
### FR2 — Tìm kiếm Tri-hybrid (Search)
|
|
16
|
+
- **Keyword Search (BM25):** Tìm chính xác theo từ khóa
|
|
17
|
+
- **Vector Search (Semantic):** Tìm theo ý nghĩa tương đồng
|
|
18
|
+
- **Graph Search (GraphRAG):** Tìm theo chuỗi liên kết nhân-quả, thời gian, cảm xúc
|
|
19
|
+
- Kết hợp 3 kết quả bằng RRF (Reciprocal Rank Fusion) reranker
|
|
20
|
+
|
|
21
|
+
### FR3 — Truy vấn liên kết (Recall & Explain)
|
|
22
|
+
- Từ một entity, đi dọc theo graph edges để tìm các sự kiện liên quan
|
|
23
|
+
- Giải thích mối liên hệ giữa 2 sự kiện/thực thể bất kỳ
|
|
24
|
+
|
|
25
|
+
### FR4 — Xem lại ký ức (Browse)
|
|
26
|
+
- Xem timeline các sự kiện trong khoảng thời gian theo thứ tự thời gian
|
|
27
|
+
- Xem danh sách các ngày đã ghi chú nhật ký
|
|
28
|
+
- Lấy danh sách entities hoặc thống kê cơ bản thông qua MCP resources
|
|
29
|
+
|
|
30
|
+
### FR5 — Prompt Templates
|
|
31
|
+
- `reflect_on_day`: Hồi tưởng cuối ngày
|
|
32
|
+
- `weekly_review`: Tổng kết tuần
|
|
33
|
+
- `find_why`: Truy vấn nguyên nhân cảm xúc/hành vi
|
|
34
|
+
|
|
35
|
+
## Non-Functional Requirements
|
|
36
|
+
|
|
37
|
+
| Yêu cầu | Mục tiêu |
|
|
38
|
+
|---|---|
|
|
39
|
+
| **Privacy** | 100% local, không gửi dữ liệu lên cloud (trừ LLM API calls) |
|
|
40
|
+
| **Latency** | Search < 2s, Save < 3s (bao gồm extraction) |
|
|
41
|
+
| **Portability** | MCP protocol → dùng được với OpenClaw, Claude Desktop, Cursor |
|
|
42
|
+
| **Durability** | Markdown = source of truth; Graph/Vector chỉ là derived index, rebuild được |
|
|
43
|
+
| **Deployment** | Docker Compose cho toàn bộ stack, chạy trên Mac Mini |
|
|
44
|
+
|
|
45
|
+
## Constraints
|
|
46
|
+
|
|
47
|
+
- Graph DB: **FalkorDB** (Docker container)
|
|
48
|
+
- Vector DB: **ChromaDB** (embedded hoặc Docker)
|
|
49
|
+
- Keyword Index: **SQLite FTS5** (file-based, trong container MCP server)
|
|
50
|
+
- Embedding: Local via **Ollama** hoặc API (Anthropic/OpenAI)
|
|
51
|
+
- Entity Extraction LLM: **Claude Haiku 4.5** via Anthropic API
|
|
52
|
+
- MCP Server: **Python + FastMCP**, chạy local
|