hipercampo 0.1.0a2__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.
- hipercampo-0.1.0a2/.github/workflows/ci.yml +54 -0
- hipercampo-0.1.0a2/.github/workflows/release.yml +32 -0
- hipercampo-0.1.0a2/.gitignore +22 -0
- hipercampo-0.1.0a2/ATTRIBUTION.md +65 -0
- hipercampo-0.1.0a2/CHANGELOG.md +41 -0
- hipercampo-0.1.0a2/Dockerfile +17 -0
- hipercampo-0.1.0a2/INSTALL.md +299 -0
- hipercampo-0.1.0a2/LICENSE +21 -0
- hipercampo-0.1.0a2/PKG-INFO +245 -0
- hipercampo-0.1.0a2/README.es.md +218 -0
- hipercampo-0.1.0a2/README.md +218 -0
- hipercampo-0.1.0a2/ROADMAP.md +86 -0
- hipercampo-0.1.0a2/SECURITY.md +99 -0
- hipercampo-0.1.0a2/docker-compose.yml +19 -0
- hipercampo-0.1.0a2/examples/01_personal_assistant.py +58 -0
- hipercampo-0.1.0a2/examples/02_project_knowledge.py +54 -0
- hipercampo-0.1.0a2/examples/03_creative_brainstorm.py +62 -0
- hipercampo-0.1.0a2/examples/04_the_long_night.py +92 -0
- hipercampo-0.1.0a2/examples/README.md +22 -0
- hipercampo-0.1.0a2/hipercampo/__init__.py +6 -0
- hipercampo-0.1.0a2/hipercampo/backup.py +67 -0
- hipercampo-0.1.0a2/hipercampo/config.py +21 -0
- hipercampo-0.1.0a2/hipercampo/encoder.py +121 -0
- hipercampo-0.1.0a2/hipercampo/memory.py +562 -0
- hipercampo-0.1.0a2/hipercampo/roles.py +149 -0
- hipercampo-0.1.0a2/hipercampo/safety.py +83 -0
- hipercampo-0.1.0a2/hipercampo/semantic.py +70 -0
- hipercampo-0.1.0a2/hipercampo/server.py +142 -0
- hipercampo-0.1.0a2/hipercampo/store.py +265 -0
- hipercampo-0.1.0a2/hipercampo/surprise.py +106 -0
- hipercampo-0.1.0a2/hipercampo/vsa.py +109 -0
- hipercampo-0.1.0a2/pyproject.toml +45 -0
- hipercampo-0.1.0a2/scripts/baselines.py +178 -0
- hipercampo-0.1.0a2/scripts/benchmark.py +165 -0
- hipercampo-0.1.0a2/scripts/demo.py +67 -0
- hipercampo-0.1.0a2/scripts/muse_demo.py +51 -0
- hipercampo-0.1.0a2/scripts/roles_demo.py +57 -0
- hipercampo-0.1.0a2/scripts/scenarios.py +99 -0
- hipercampo-0.1.0a2/scripts/stress.py +130 -0
- hipercampo-0.1.0a2/tests/test_axes.py +92 -0
- hipercampo-0.1.0a2/tests/test_calibration.py +112 -0
- hipercampo-0.1.0a2/tests/test_dream.py +69 -0
- hipercampo-0.1.0a2/tests/test_factstore.py +78 -0
- hipercampo-0.1.0a2/tests/test_guardrails.py +103 -0
- hipercampo-0.1.0a2/tests/test_hardening.py +96 -0
- hipercampo-0.1.0a2/tests/test_memory.py +171 -0
- hipercampo-0.1.0a2/tests/test_muse.py +99 -0
- hipercampo-0.1.0a2/tests/test_namespaces.py +138 -0
- hipercampo-0.1.0a2/tests/test_properties.py +172 -0
- hipercampo-0.1.0a2/tests/test_roles.py +77 -0
- hipercampo-0.1.0a2/tests/test_safety.py +79 -0
- hipercampo-0.1.0a2/tests/test_semantic.py +55 -0
- hipercampo-0.1.0a2/tests/test_surprise.py +57 -0
- hipercampo-0.1.0a2/tests/test_update.py +79 -0
- hipercampo-0.1.0a2/tests/test_vsa.py +44 -0
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
python-version: ["3.11", "3.12", "3.13"]
|
|
16
|
+
steps:
|
|
17
|
+
- uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Set up Python ${{ matrix.python-version }}
|
|
20
|
+
uses: actions/setup-python@v5
|
|
21
|
+
with:
|
|
22
|
+
python-version: ${{ matrix.python-version }}
|
|
23
|
+
|
|
24
|
+
- name: Install
|
|
25
|
+
run: pip install -e .
|
|
26
|
+
|
|
27
|
+
- name: Test suite (todas las suites, incluidas las generativas)
|
|
28
|
+
run: |
|
|
29
|
+
set -e
|
|
30
|
+
for t in vsa semantic surprise memory update axes hardening namespaces calibration roles safety factstore guardrails muse dream properties; do
|
|
31
|
+
echo "::group::test_$t"
|
|
32
|
+
python tests/test_$t.py
|
|
33
|
+
echo "::endgroup::"
|
|
34
|
+
done
|
|
35
|
+
|
|
36
|
+
benchmarks:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
needs: test
|
|
39
|
+
steps:
|
|
40
|
+
- uses: actions/checkout@v4
|
|
41
|
+
- uses: actions/setup-python@v5
|
|
42
|
+
with:
|
|
43
|
+
python-version: "3.13"
|
|
44
|
+
- name: Install
|
|
45
|
+
run: pip install -e .
|
|
46
|
+
- name: Benchmark de calidad (modo léxico)
|
|
47
|
+
run: python scripts/benchmark.py
|
|
48
|
+
- name: Banco de estrés (10 hechos + 10 distractores confusos)
|
|
49
|
+
run: python scripts/stress.py
|
|
50
|
+
- name: Comparativa con baselines (BM25 vs hipercampo, léxico)
|
|
51
|
+
run: python scripts/baselines.py
|
|
52
|
+
- name: Ejemplos de uso (smoke)
|
|
53
|
+
run: |
|
|
54
|
+
for e in examples/*.py; do echo "== $e =="; python "$e"; done
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
name: Release to PyPI
|
|
2
|
+
|
|
3
|
+
# Publica en PyPI al empujar un tag vX.Y.Z. Usa "trusted publishing" (OIDC): sin
|
|
4
|
+
# tokens ni secretos. Requiere una configuración ÚNICA en PyPI (ver más abajo).
|
|
5
|
+
#
|
|
6
|
+
# Pasos de un solo uso (los hace el dueño del paquete):
|
|
7
|
+
# 1. Crear el proyecto/nombre "hipercampo" en https://pypi.org
|
|
8
|
+
# 2. En "Publishing", añadir un Trusted Publisher de GitHub Actions:
|
|
9
|
+
# owner: armandojaleo repo: hipercampo workflow: release.yml
|
|
10
|
+
# 3. A partir de ahí, cada tag vX.Y.Z publica solo.
|
|
11
|
+
|
|
12
|
+
on:
|
|
13
|
+
push:
|
|
14
|
+
tags: ["v*"]
|
|
15
|
+
|
|
16
|
+
jobs:
|
|
17
|
+
publish:
|
|
18
|
+
runs-on: ubuntu-latest
|
|
19
|
+
environment: pypi
|
|
20
|
+
permissions:
|
|
21
|
+
id-token: write # necesario para trusted publishing (OIDC)
|
|
22
|
+
steps:
|
|
23
|
+
- uses: actions/checkout@v4
|
|
24
|
+
- uses: actions/setup-python@v5
|
|
25
|
+
with:
|
|
26
|
+
python-version: "3.13"
|
|
27
|
+
- name: Build
|
|
28
|
+
run: |
|
|
29
|
+
pip install build
|
|
30
|
+
python -m build
|
|
31
|
+
- name: Publish to PyPI
|
|
32
|
+
uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Python
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*.egg-info/
|
|
5
|
+
.venv/
|
|
6
|
+
venv/
|
|
7
|
+
build/
|
|
8
|
+
dist/
|
|
9
|
+
|
|
10
|
+
# Datos de memoria (no versionar)
|
|
11
|
+
data/
|
|
12
|
+
*.db
|
|
13
|
+
|
|
14
|
+
# IDE / OS
|
|
15
|
+
.DS_Store
|
|
16
|
+
.idea/
|
|
17
|
+
.vscode/
|
|
18
|
+
|
|
19
|
+
# Configuración local del usuario (rutas y ajustes personales, no portables)
|
|
20
|
+
.claude/
|
|
21
|
+
.mcp.json
|
|
22
|
+
*.bak-*
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Atribución y procedencia
|
|
2
|
+
|
|
3
|
+
Este proyecto es explícito sobre qué es original y qué debe crédito a terceros.
|
|
4
|
+
Regla de la casa: **si usamos trabajo de otros, sobre todo con copyright, se dice.**
|
|
5
|
+
|
|
6
|
+
## Código
|
|
7
|
+
|
|
8
|
+
**Todo el código de `hipercampo/` es original**, escrito para este proyecto (por
|
|
9
|
+
Armando Jaleo con asistencia de Claude, de Anthropic). No se ha copiado código con
|
|
10
|
+
copyright de otros proyectos. El álgebra de hipervectores (`bind`=XOR,
|
|
11
|
+
`bundle`=voto por mayoría, `permute`=rotación, distancia de Hamming) son
|
|
12
|
+
operaciones matemáticas estándar de dominio público, no una implementación ajena.
|
|
13
|
+
|
|
14
|
+
## Dependencias de software (con su licencia)
|
|
15
|
+
|
|
16
|
+
Se instalan por separado vía `pip`; **su código no se incluye** en este repositorio.
|
|
17
|
+
|
|
18
|
+
| Dependencia | Uso | Licencia |
|
|
19
|
+
|-------------|-----|----------|
|
|
20
|
+
| [NumPy](https://numpy.org) | operaciones sobre los hipervectores | BSD-3-Clause |
|
|
21
|
+
| [MCP Python SDK](https://github.com/modelcontextprotocol/python-sdk) | servidor MCP (`FastMCP`) | MIT |
|
|
22
|
+
| Python (stdlib: `sqlite3`, `hashlib`, `re`) | persistencia y utilidades | PSF |
|
|
23
|
+
|
|
24
|
+
Cada una conserva su propia licencia y copyright.
|
|
25
|
+
|
|
26
|
+
### Dependencia OPCIONAL del hook semántico (no se instala por defecto)
|
|
27
|
+
|
|
28
|
+
Solo si activas la semántica con `pip install hipercampo[semantic]`:
|
|
29
|
+
|
|
30
|
+
| Dependencia / recurso | Uso | Licencia |
|
|
31
|
+
|-----------------------|-----|----------|
|
|
32
|
+
| [sentence-transformers](https://github.com/UKPLab/sentence-transformers) | generar embeddings densos | Apache-2.0 |
|
|
33
|
+
| Modelo `paraphrase-multilingual-MiniLM-L12-v2` (por defecto) | embeddings multilingües | Apache-2.0 (autores del modelo) |
|
|
34
|
+
|
|
35
|
+
El puente SimHash (`semantic.embedding_to_hv`) que convierte esos embeddings en
|
|
36
|
+
hipervectores es **código original nuestro**. El modelo lo descarga el usuario y se
|
|
37
|
+
rige por su propia licencia; puedes sustituirlo por cualquier otro con `make_hook`.
|
|
38
|
+
|
|
39
|
+
## Ideas y trabajo académico en el que nos inspiramos
|
|
40
|
+
|
|
41
|
+
hipercampo **no implementa** estos trabajos; se inspira en sus ideas y las cita
|
|
42
|
+
como es debido. Los conceptos son de sus autores:
|
|
43
|
+
|
|
44
|
+
- **Pentti Kanerva** — *Sparse Distributed Memory* (memoria asociativa dispersa).
|
|
45
|
+
- **Tony A. Plate** — *Holographic Reduced Representations* (HRR / binding).
|
|
46
|
+
- **Torchhd** — Heddes et al., *JMLR* 2023: librería de referencia HD/VSA. La
|
|
47
|
+
citamos como estado del arte; **no usamos su código** (implementamos VSA propio).
|
|
48
|
+
- Línea reciente de memoria en LLMs (2024-2026): **Titans**, **MIRAS**, **HippoRAG**,
|
|
49
|
+
**MemGPT / Letta**, **Mem0**, **Graphiti**, y **MnemoCore** (HDC/VSA para memoria de
|
|
50
|
+
IA), además de la relación *atención ≈ SDM* (Bricken & Pehlevan, 2021). Sirvieron
|
|
51
|
+
para situar el hueco a explorar; ninguna aportó código a este repo. hipercampo no
|
|
52
|
+
reclama inventar HDC ni la memoria de agentes: reclama una *combinación* concreta
|
|
53
|
+
(VSA + sorpresa + consolidación + olvido, vía MCP).
|
|
54
|
+
|
|
55
|
+
## El "hook" semántico opcional
|
|
56
|
+
|
|
57
|
+
`encoder.set_semantic_hook()` permite enchufar un codificador semántico externo
|
|
58
|
+
(por ejemplo un modelo de embeddings). **hipercampo no incluye ningún modelo.**
|
|
59
|
+
Si conectas uno, ese modelo trae su propia licencia y sus propios términos, y eres
|
|
60
|
+
tú quien los acepta: decláralo en tu despliegue.
|
|
61
|
+
|
|
62
|
+
## Cómo citar hipercampo
|
|
63
|
+
|
|
64
|
+
> Jaleo, A. (2026). *hipercampo: memoria asociativa para LLMs basada en
|
|
65
|
+
> hipervectores*. https://github.com/armandojaleo/hipercampo
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project are documented here. Format loosely based on
|
|
4
|
+
[Keep a Changelog](https://keepachangelog.com/); versions follow [SemVer](https://semver.org/).
|
|
5
|
+
|
|
6
|
+
## [0.1.0a1] — 2026-07-22
|
|
7
|
+
|
|
8
|
+
First public alpha. Local-first, single-user memory for Claude via MCP.
|
|
9
|
+
|
|
10
|
+
### Added
|
|
11
|
+
- **Memory cycle**: surprise-gated writing (double veto: redundant + predictable via
|
|
12
|
+
an in-house incremental LM / MDL, with an *adaptive* threshold), spreading-activation
|
|
13
|
+
recall with **abstention**, sleep **consolidation** (structural, optional summarizer),
|
|
14
|
+
and **active forgetting** driven by a transparent retention value.
|
|
15
|
+
- **Four separated axes**: novelty, importance, reliability (`confidence`), utility.
|
|
16
|
+
- **Fact updates** (`hc_update`): safe supersession by id or minimum similarity.
|
|
17
|
+
- **Compositional roles** (`hc_remember_fact` / `hc_ask_role`): store subject-predicate-
|
|
18
|
+
object facts and query by role via VSA unbinding (distinguishes a fact from its reverse).
|
|
19
|
+
- **Contexts**: namespace isolation (reads, id-writes and links), enforced in depth.
|
|
20
|
+
- **Reliability**: SQLite WAL + `busy_timeout`, reentrant transactions, input validation.
|
|
21
|
+
- **Performance**: vectorized similarity (native popcount) — ~5× faster scans.
|
|
22
|
+
- **Safeguards**: secret-detection warnings, injection flagging of recalled memories,
|
|
23
|
+
optional secret **redaction** (`HIPERCAMPO_REDACT_SECRETS`) and per-context memory
|
|
24
|
+
**cap** (`HIPERCAMPO_MAX_MEMORIES`).
|
|
25
|
+
- **Optional semantic hook** (SimHash bridge over sentence-transformers).
|
|
26
|
+
- Docs (EN/ES), SECURITY, ATTRIBUTION, ROADMAP; 16 test suites + CI (Python 3.11–3.13)
|
|
27
|
+
running tests, benchmarks and a baseline comparison (BM25 / embeddings).
|
|
28
|
+
|
|
29
|
+
### Added (post-tag, unreleased)
|
|
30
|
+
- **Dormant memory & creative recall**: forgetting now *archives* memories as
|
|
31
|
+
`dormant` (not deleted, like the human mind); `hc_muse` performs serendipitous
|
|
32
|
+
recall — favoring indirect associations and resurfacing dormant memories to tie
|
|
33
|
+
ideas together (insight/brainstorming).
|
|
34
|
+
|
|
35
|
+
### Known limits (declared, not hidden)
|
|
36
|
+
- Retrieval is linear (no ANN index): fine for hundreds–thousands of memories.
|
|
37
|
+
- Surprise counters are not fully persisted (rebuilt from stored memories on start).
|
|
38
|
+
- Benchmarks are small/synthetic — a signal, not proof at scale.
|
|
39
|
+
- Local, single-user scope: no auth/encryption/multi-user isolation.
|
|
40
|
+
|
|
41
|
+
[0.1.0a1]: https://github.com/armandojaleo/hipercampo/releases/tag/v0.1.0-alpha
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Imagen mínima para el servidor MCP de hipercampo.
|
|
2
|
+
FROM python:3.13-slim
|
|
3
|
+
|
|
4
|
+
WORKDIR /app
|
|
5
|
+
|
|
6
|
+
# Dependencias primero (mejor cache de capas)
|
|
7
|
+
COPY pyproject.toml README.md ./
|
|
8
|
+
COPY hipercampo ./hipercampo
|
|
9
|
+
|
|
10
|
+
RUN pip install --no-cache-dir .
|
|
11
|
+
|
|
12
|
+
# La memoria persiste en el volumen /data (ver docker-compose.yml)
|
|
13
|
+
ENV HIPERCAMPO_DB=/data/hipercampo.db
|
|
14
|
+
VOLUME ["/data"]
|
|
15
|
+
|
|
16
|
+
# MCP habla por stdio: mantener STDIN abierto con `docker run -i`.
|
|
17
|
+
ENTRYPOINT ["python", "-m", "hipercampo.server"]
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
# Guía de instalación de hipercampo
|
|
2
|
+
|
|
3
|
+
De cero a "Claude tiene memoria" en unos minutos. Elige **una** de las dos vías
|
|
4
|
+
(A: Python local — la más simple para empezar; B: Docker — más portable).
|
|
5
|
+
|
|
6
|
+
Requisitos: **Python 3.11+** (vía A) o **Docker** (vía B). Windows, macOS o Linux.
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Paso 0 · Conseguir el código
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
git clone https://github.com/armandojaleo/hipercampo.git
|
|
14
|
+
cd hipercampo
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## Vía A · Python local (recomendada para empezar)
|
|
20
|
+
|
|
21
|
+
### A.1 Instalar
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
pip install -e .
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Esto instala `hipercampo` y su única dependencia real (numpy) + el SDK de MCP.
|
|
28
|
+
|
|
29
|
+
### A.2 Comprobar que funciona (sin Claude todavía)
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
python scripts/demo.py # ves el ciclo completo: sorpresa, recuerdo, sueño, olvido
|
|
33
|
+
python -m pytest -q # o: python tests/test_memory.py
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### A.3 Arrancar el servidor MCP a mano (opcional, para verlo vivo)
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
python -m hipercampo.server
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Se queda esperando por stdio (es lo normal en MCP). Córtalo con Ctrl+C. No hace
|
|
43
|
+
falta lanzarlo tú: lo lanzará Claude automáticamente al conectarlo (paso siguiente).
|
|
44
|
+
|
|
45
|
+
---
|
|
46
|
+
|
|
47
|
+
## Vía B · Docker
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
docker compose build
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
La memoria se guarda en el volumen `hipercampo_data`. Para una prueba manual:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
docker compose run --rm hipercampo # arranca el server (stdio); Ctrl+C para salir
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
---
|
|
60
|
+
|
|
61
|
+
## Paso final · Conectar con Claude
|
|
62
|
+
|
|
63
|
+
### Claude Code (CLI / extensión de VSCode)
|
|
64
|
+
|
|
65
|
+
**Opción 1 — con el comando** (desde la carpeta del proyecto):
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
# Vía A (Python):
|
|
69
|
+
claude mcp add hipercampo -- python -m hipercampo.server
|
|
70
|
+
|
|
71
|
+
# Vía B (Docker):
|
|
72
|
+
claude mcp add hipercampo -- docker run --rm -i -v hipercampo_data:/data hipercampo:latest
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Opción 2 — a mano**: crea un archivo `.mcp.json` en la raíz del proyecto:
|
|
76
|
+
|
|
77
|
+
```json
|
|
78
|
+
{
|
|
79
|
+
"mcpServers": {
|
|
80
|
+
"hipercampo": {
|
|
81
|
+
"command": "python",
|
|
82
|
+
"args": ["-m", "hipercampo.server"],
|
|
83
|
+
"env": { "HIPERCAMPO_DB": "./data/hipercampo.db" }
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Reinicia Claude Code. Deberías ver 10 herramientas: `hc_remember`, `hc_recall`,
|
|
90
|
+
`hc_update`, `hc_consolidate`, `hc_forget`, `hc_stats`.
|
|
91
|
+
|
|
92
|
+
### Memoria compartida entre TODOS los proyectos (global)
|
|
93
|
+
|
|
94
|
+
El `.mcp.json` del paso anterior activa hipercampo **solo en ese proyecto**. Como la
|
|
95
|
+
base de datos ya vive en una ruta global (`~/.hipercampo/hipercampo.db`), los datos
|
|
96
|
+
se comparten igual; lo único "por proyecto" es el registro del servidor.
|
|
97
|
+
|
|
98
|
+
Para que Claude tenga las herramientas en **cualquier** proyecto, registra el
|
|
99
|
+
servidor a nivel **usuario**:
|
|
100
|
+
|
|
101
|
+
```bash
|
|
102
|
+
claude mcp add --scope user hipercampo -- python -m hipercampo.server
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
O a mano, añade un bloque `mcpServers` de nivel raíz en `~/.claude.json` (Claude
|
|
106
|
+
Code) — misma forma que el `.mcp.json`, pero en el archivo global del usuario. Usa
|
|
107
|
+
rutas absolutas del ejecutable de Python y de `HIPERCAMPO_DB`. Reinicia Claude Code.
|
|
108
|
+
|
|
109
|
+
> Puedes tener ambos (global + `.mcp.json` del repo): si apuntan a la misma BD y
|
|
110
|
+
> comando, es inofensivo. El `.mcp.json` del repo es útil para quien clone el proyecto.
|
|
111
|
+
|
|
112
|
+
### Aislar contextos: namespaces (recomendado) o ficheros distintos
|
|
113
|
+
|
|
114
|
+
Dos formas de que lo de un proyecto no se mezcle con otro (local-first, ambas válidas):
|
|
115
|
+
|
|
116
|
+
**Opción A — namespaces (una sola BD).** Añade `HIPERCAMPO_NAMESPACE` al `env` de
|
|
117
|
+
cada servidor. Cada recuerdo lleva su contexto y **nada cruza** (lecturas, escrituras
|
|
118
|
+
por id y enlaces, todo acotado):
|
|
119
|
+
|
|
120
|
+
```json
|
|
121
|
+
"env": {
|
|
122
|
+
"HIPERCAMPO_DB": "C:/Users/tu/.hipercampo/hipercampo.db",
|
|
123
|
+
"HIPERCAMPO_NAMESPACE": "mplayer"
|
|
124
|
+
}
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
**Opción B — ficheros distintos.** Un `HIPERCAMPO_DB` por proyecto (abajo). Es
|
|
128
|
+
aislamiento **local entre contextos**, no una frontera de seguridad multiusuario
|
|
129
|
+
(ver [SECURITY.md](SECURITY.md)).
|
|
130
|
+
|
|
131
|
+
### Híbrida: memoria personal + memoria por proyecto
|
|
132
|
+
|
|
133
|
+
Dos servidores con **BD distinta** (o mismo fichero y distinto namespace), para que
|
|
134
|
+
lo técnico de un proyecto no se mezcle con otro pero Claude te siga conociendo:
|
|
135
|
+
|
|
136
|
+
**1) Personal (global, `~/.claude.json`)** — un servidor `memoria` con su propia BD:
|
|
137
|
+
|
|
138
|
+
```json
|
|
139
|
+
"mcpServers": {
|
|
140
|
+
"memoria": {
|
|
141
|
+
"command": "C:/Python313/python.exe",
|
|
142
|
+
"args": ["-m", "hipercampo.server"],
|
|
143
|
+
"env": { "HIPERCAMPO_DB": "C:/Users/tu/.hipercampo/personal.db" }
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**2) Por proyecto (`.mcp.json` en la raíz de cada proyecto)** — un servidor
|
|
149
|
+
`proyecto` con una BD propia por proyecto:
|
|
150
|
+
|
|
151
|
+
```json
|
|
152
|
+
{
|
|
153
|
+
"mcpServers": {
|
|
154
|
+
"proyecto": {
|
|
155
|
+
"command": "C:/Python313/python.exe",
|
|
156
|
+
"args": ["-m", "hipercampo.server"],
|
|
157
|
+
"env": { "HIPERCAMPO_DB": "C:/Users/tu/.hipercampo/proj-NOMBRE.db" }
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Cambia `proj-NOMBRE.db` por proyecto (`proj-mplayer.db`, `proj-web.db`...). Claude
|
|
164
|
+
verá dos juegos de herramientas (`memoria` y `proyecto`) y elegirá dónde guardar
|
|
165
|
+
cada cosa. Para copiar tu memoria actual a la personal: `python -m hipercampo.backup
|
|
166
|
+
C:/Users/tu/.hipercampo/personal.db` (con `HIPERCAMPO_DB` apuntando a la vieja).
|
|
167
|
+
|
|
168
|
+
### Claude Desktop
|
|
169
|
+
|
|
170
|
+
Edita el archivo de configuración:
|
|
171
|
+
|
|
172
|
+
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
173
|
+
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
174
|
+
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"mcpServers": {
|
|
178
|
+
"hipercampo": {
|
|
179
|
+
"command": "docker",
|
|
180
|
+
"args": ["run", "--rm", "-i",
|
|
181
|
+
"-v", "hipercampo_data:/data",
|
|
182
|
+
"hipercampo:latest"]
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
(O con Python: `"command": "python"`, `"args": ["-m", "hipercampo.server"]`, y
|
|
189
|
+
`"env": {"HIPERCAMPO_DB": "C:/ruta/a/hipercampo.db"}`.)
|
|
190
|
+
|
|
191
|
+
Reinicia Claude Desktop.
|
|
192
|
+
|
|
193
|
+
---
|
|
194
|
+
|
|
195
|
+
## Comprobar que Claude ya tiene memoria
|
|
196
|
+
|
|
197
|
+
En una conversación con Claude, pídele:
|
|
198
|
+
|
|
199
|
+
> «Guarda en tu memoria que prefiero respuestas directas» → usará `hc_remember`.
|
|
200
|
+
> Más tarde: «¿qué recuerdas sobre cómo prefiero que me hables?» → usará `hc_recall`.
|
|
201
|
+
|
|
202
|
+
También puedes verificar el servidor sin Claude, con un handshake MCP crudo:
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
printf '%s\n' \
|
|
206
|
+
'{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"t","version":"0"}}}' \
|
|
207
|
+
'{"jsonrpc":"2.0","method":"notifications/initialized"}' \
|
|
208
|
+
'{"jsonrpc":"2.0","id":2,"method":"tools/list"}' | python -m hipercampo.server
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
Debe listar las 10 herramientas `hc_*`.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## Controlar y respaldar la memoria
|
|
216
|
+
|
|
217
|
+
Toda la memoria de hipercampo es **un único fichero SQLite**. Fácil de ver, mover,
|
|
218
|
+
copiar o borrar.
|
|
219
|
+
|
|
220
|
+
### ¿Dónde está?
|
|
221
|
+
|
|
222
|
+
Por defecto:
|
|
223
|
+
|
|
224
|
+
- **Local (Windows)**: `C:\Users\<tú>\.hipercampo\hipercampo.db`
|
|
225
|
+
- **Local (macOS/Linux)**: `~/.hipercampo/hipercampo.db`
|
|
226
|
+
- **Docker**: dentro del volumen `hipercampo_data` (`/data/hipercampo.db`)
|
|
227
|
+
|
|
228
|
+
Puedes cambiarla con la variable **`HIPERCAMPO_DB`** (en el `env` de la config MCP,
|
|
229
|
+
o al lanzar el server). Y puedes preguntárselo a Claude: la herramienta `hc_stats`
|
|
230
|
+
devuelve el campo `db` con la ruta absoluta.
|
|
231
|
+
|
|
232
|
+
### Controlar su uso desde Claude
|
|
233
|
+
|
|
234
|
+
Las 10 herramientas te dan control total, sin tocar código:
|
|
235
|
+
|
|
236
|
+
| Quieres… | Pídele a Claude (usa la tool) |
|
|
237
|
+
|----------|-------------------------------|
|
|
238
|
+
| Ver cuánto recuerda y dónde | `hc_stats` |
|
|
239
|
+
| Que guarde algo concreto | `hc_remember` (con `importance` alta para que no se olvide) |
|
|
240
|
+
| Que recuerde algo | `hc_recall` |
|
|
241
|
+
| Actualizar un hecho que cambió | `hc_update` |
|
|
242
|
+
| Condensar (fase de sueño) | `hc_consolidate` |
|
|
243
|
+
| Podar lo viejo/trivial | `hc_forget` (usa `dry_run=true` para ver antes qué se iría) |
|
|
244
|
+
| Empezar de cero | cierra el server y borra el fichero `.db` |
|
|
245
|
+
|
|
246
|
+
Los umbrales (cuándo algo es "novedoso", "predecible", cuándo se olvida) están al
|
|
247
|
+
inicio de [`hipercampo/memory.py`](hipercampo/memory.py) — comentados y ajustables.
|
|
248
|
+
|
|
249
|
+
### Backup y restauración
|
|
250
|
+
|
|
251
|
+
```bash
|
|
252
|
+
# Copia de seguridad (consistente, aunque el server esté activo):
|
|
253
|
+
python -m hipercampo.backup # -> <db>.YYYYMMDD-HHMMSS.bak
|
|
254
|
+
python -m hipercampo.backup C:\copias\hc.db # -> a la ruta que elijas
|
|
255
|
+
|
|
256
|
+
# Restaurar desde una copia:
|
|
257
|
+
python -m hipercampo.backup --restore C:\copias\hc.db
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
O simplemente **copia el fichero `.db`** con el server parado; es igual de válido.
|
|
261
|
+
En Docker: `docker run --rm -v hipercampo_data:/data -v "%cd%":/backup alpine \
|
|
262
|
+
cp /data/hipercampo.db /backup/`.
|
|
263
|
+
|
|
264
|
+
---
|
|
265
|
+
|
|
266
|
+
## Semántica opcional (para sinónimos)
|
|
267
|
+
|
|
268
|
+
Por defecto hipercampo es léxico (CPU, sin GPU). Si quieres que capte sinónimos:
|
|
269
|
+
|
|
270
|
+
```bash
|
|
271
|
+
pip install -e ".[semantic]" # trae sentence-transformers (Apache-2.0)
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
Y actívala en el servidor con una variable de entorno (en el `env` de tu config MCP):
|
|
275
|
+
|
|
276
|
+
```json
|
|
277
|
+
"env": {
|
|
278
|
+
"HIPERCAMPO_DB": "C:/Users/tu/.hipercampo/hipercampo.db",
|
|
279
|
+
"HIPERCAMPO_SEMANTIC": "1"
|
|
280
|
+
}
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
(O en código: `from hipercampo import encoder; encoder.enable_semantic()`.)
|
|
284
|
+
|
|
285
|
+
Sube el MRR global de recuperación de **0.77 a 0.95** en el banco de estrés
|
|
286
|
+
(`python scripts/stress.py --semantic`). La 1ª vez descarga el modelo. Ver
|
|
287
|
+
[ATTRIBUTION.md](ATTRIBUTION.md) para licencias del modelo.
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
|
|
291
|
+
## Problemas frecuentes
|
|
292
|
+
|
|
293
|
+
| Síntoma | Causa / solución |
|
|
294
|
+
|---|---|
|
|
295
|
+
| `No module named hipercampo` | No hiciste `pip install -e .` en la carpeta del proyecto. |
|
|
296
|
+
| Claude no ve las herramientas | Reinicia el cliente tras editar la config; revisa que la ruta/comando sea correcta. |
|
|
297
|
+
| El comando `hipercampo` no existe | Usa `python -m hipercampo.server` (el script de consola puede no estar en el PATH). |
|
|
298
|
+
| Docker: "cannot access stdin" | Falta `-i` en `docker run` (MCP habla por stdin). |
|
|
299
|
+
| La memoria "se pierde" | En Docker, comprueba que montas el volumen `-v hipercampo_data:/data`. |
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Armando Jaleo
|
|
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.
|