anamne 0.3.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.
@@ -0,0 +1,16 @@
1
+ # PROVENANCE — Environment Configuration
2
+ # Copy this file to .env, then run: provenance init
3
+
4
+ # Pick ONE of these (in priority order — first non-empty wins):
5
+
6
+ # Best quality, paid (~$0.003/commit). Get a key at https://platform.anthropic.com
7
+ # ANTHROPIC_API_KEY=sk-ant-...
8
+
9
+ # Free tier, good quality. Get a key at https://aistudio.google.com/apikey
10
+ # GEMINI_API_KEY=...
11
+
12
+ # Or use a local Ollama model (free, offline, ~4GB disk, lower quality)
13
+ # MODEL=ollama/llama3.2
14
+
15
+ # Optional: where to store the knowledge base (default: ~/.provenance)
16
+ # DATA_DIR=C:/Users/YourName/.provenance
@@ -0,0 +1,20 @@
1
+ # Consistent line endings across all platforms
2
+ * text=auto
3
+
4
+ # Source files always LF
5
+ *.py text eol=lf
6
+ *.md text eol=lf
7
+ *.toml text eol=lf
8
+ *.yml text eol=lf
9
+ *.yaml text eol=lf
10
+ *.txt text eol=lf
11
+ *.json text eol=lf
12
+ *.sh text eol=lf
13
+
14
+ # Binary files — never touch line endings
15
+ *.db binary
16
+ *.sqlite binary
17
+ *.png binary
18
+ *.jpg binary
19
+ *.docx binary
20
+ *.pdf binary
@@ -0,0 +1,39 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ branches: [master, main]
6
+ pull_request:
7
+ branches: [master, main]
8
+
9
+ jobs:
10
+ test:
11
+ name: Tests (Python ${{ matrix.python-version }})
12
+ runs-on: ubuntu-latest
13
+ strategy:
14
+ matrix:
15
+ python-version: ["3.12"]
16
+
17
+ steps:
18
+ - uses: actions/checkout@v4
19
+
20
+ - name: Set up Python ${{ matrix.python-version }}
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+
25
+ - name: Cache pip
26
+ uses: actions/cache@v4
27
+ with:
28
+ path: ~/.cache/pip
29
+ key: ${{ runner.os }}-pip-${{ hashFiles('pyproject.toml') }}
30
+ restore-keys: |
31
+ ${{ runner.os }}-pip-
32
+
33
+ - name: Install package and dev dependencies
34
+ run: |
35
+ python -m pip install --upgrade pip
36
+ pip install -e ".[dev]"
37
+
38
+ - name: Run tests
39
+ run: python -m pytest tests/ -v
@@ -0,0 +1,40 @@
1
+ name: Publish to PyPI
2
+
3
+ # Triggers when you push a version tag (e.g. v0.3.0)
4
+ on:
5
+ push:
6
+ tags:
7
+ - "v[0-9]+.[0-9]+.[0-9]+"
8
+
9
+ jobs:
10
+ build-and-publish:
11
+ name: Build and publish to PyPI
12
+ runs-on: ubuntu-latest
13
+ environment: pypi # requires a "pypi" environment configured in repo settings
14
+
15
+ permissions:
16
+ id-token: write # required for Trusted Publishing (no PyPI token needed)
17
+
18
+ steps:
19
+ - uses: actions/checkout@v4
20
+
21
+ - name: Set up Python
22
+ uses: actions/setup-python@v5
23
+ with:
24
+ python-version: "3.12"
25
+
26
+ - name: Install build tools
27
+ run: |
28
+ python -m pip install --upgrade pip
29
+ pip install build
30
+
31
+ - name: Build distributions
32
+ run: python -m build
33
+
34
+ - name: Publish to PyPI
35
+ uses: pypa/gh-action-pypi-publish@release/v1
36
+ # Uses PyPI Trusted Publishing — no token needed, configure here:
37
+ # https://pypi.org/manage/account/publishing/
38
+ # Repository: venumittapalli576/anamne
39
+ # Workflow: publish.yml
40
+ # Environment: pypi
@@ -0,0 +1,31 @@
1
+ # Environment — NEVER commit this
2
+ .env
3
+
4
+ # Python
5
+ __pycache__/
6
+ *.py[cod]
7
+ *.egg-info/
8
+ dist/
9
+ build/
10
+ .venv/
11
+ venv/
12
+
13
+ # ANAMNE data — stays local
14
+ .anamne/
15
+
16
+ # IDE
17
+ .vscode/
18
+ .idea/
19
+ *.swp
20
+
21
+ # OS
22
+ .DS_Store
23
+ Thumbs.db
24
+
25
+ # Generated artifacts
26
+ ANAMNE_*.docx
27
+ PROVENANCE_*.docx
28
+ scripts/node_modules/
29
+ scripts/package-lock.json
30
+ scripts/package.json
31
+ test-repo/
@@ -0,0 +1,249 @@
1
+ # I Built a Tool, Found a Competitor, Read Two Research Papers, and Pivoted in 48 Hours
2
+
3
+ *A software engineering war story about rapid iteration, research literacy, and the right time to stop.*
4
+
5
+ ---
6
+
7
+ ## The Original Idea
8
+
9
+ Every codebase has a graveyard of decisions. Why did we switch from MySQL to Postgres? Why does the
10
+ payment service live in a separate repo? Why is there a Redis cluster when the database handles
11
+ sessions fine?
12
+
13
+ These answers live in Slack threads, ancient commit messages, people's heads. They're lost as soon
14
+ as the team grows or memory fades. I wanted to fix that.
15
+
16
+ The idea: index git history with an LLM, extract "why" decisions from commit messages and ADRs,
17
+ store them in a searchable graph, and surface them via an MCP server directly in your editor.
18
+
19
+ I called it **ANAMNE** and built it in a weekend.
20
+
21
+ ```bash
22
+ anamne index ./my-repo
23
+ anamne ask "why was Redis added to this codebase?"
24
+ ```
25
+
26
+ It worked. Claude answered with citations from actual commit messages. The demo was clean.
27
+
28
+ ---
29
+
30
+ ## The Competitor Problem
31
+
32
+ Then I did what you should always do before claiming novelty: searched for existing tools.
33
+
34
+ **Repowise** does exactly what I built. So does **GitMind**. Multiple well-funded products with
35
+ better UI, more integrations, and a head start.
36
+
37
+ The first reaction: rebuild something else. Start over. Find a gap that doesn't exist yet.
38
+
39
+ I nearly did. I spent hours searching for "the next idea" — AI memory tools, code documentation
40
+ generators, context compression systems. Every category had competition. Some had more than one.
41
+
42
+ The actual lesson wasn't "the idea is wrong." It was: **this is 2026. Every obvious idea has
43
+ competition.** Starting over doesn't solve that.
44
+
45
+ ---
46
+
47
+ ## The Research Pivot
48
+
49
+ Instead of rebuilding, I read papers.
50
+
51
+ Three caught my eye:
52
+
53
+ **LIGHT** (arXiv 2510.27246) — a 2026 paper proposing a three-layer memory architecture for AI
54
+ agents. The analogy to human memory was explicit:
55
+
56
+ - *Episodic memory* (hippocampal long-term store): full records of past events
57
+ - *Scratchpad* (semantic memory): distilled facts and truths
58
+ - *Working memory* (prefrontal cortex): what you're holding in your head right now
59
+
60
+ The paper showed that combining all three layers with explicit conflict resolution produced
61
+ significantly better recall than single-store approaches.
62
+
63
+ **Agent Cognitive Compressor** — "bounded compressed state": as an AI's memory grows, you can't
64
+ fit all of it in the context window. The solution is hierarchical: keep the top-K items verbatim,
65
+ compress the lower-priority tail into a compact summary. This bounds the prompt size regardless of
66
+ how much history you've stored.
67
+
68
+ **ACT-R memory architecture** — cognitive science model of how humans retrieve memories. Key
69
+ insight: retrieval probability isn't just about relevance — it's modulated by recency and frequency
70
+ of use. Items used more recently and more often have higher "activation" and are more likely to be
71
+ retrieved.
72
+
73
+ Reading these, I realized: **my architecture was already halfway there.** I had ChromaDB for
74
+ semantic search (episodic), SQLite for structured storage, and an LLM for synthesis. The core
75
+ pieces were right. I just needed to implement the full three-layer design and ground the
76
+ abstractions in the actual papers.
77
+
78
+ ---
79
+
80
+ ## What Changed
81
+
82
+ Over two days I refactored ANAMNE from "git WHY tool" to "personal memory layer":
83
+
84
+ **Layer 1 — Episodic memory** (already existed, renamed/clarified):
85
+ - ChromaDB semantic search over all past decisions
86
+ - SQLite for bi-temporal storage (created_at, valid_until)
87
+ - Indexed from git history, ADR files
88
+
89
+ **Layer 2 — Scratchpad** (new):
90
+ - Explicit `remember()` API for durable facts
91
+ - LLM-based distillation: paste a wall of text, get N atomic facts extracted
92
+ - ACT-R activation tracking: `last_used`, `use_count` updated on every recall
93
+ - `forget()` for explicit deletion
94
+ - `consolidate()` to merge redundant facts (analogous to sleep-phase consolidation)
95
+
96
+ **Layer 3 — Working memory** (new):
97
+ - Short-lived session notes with TTL expiry
98
+ - "Currently debugging the auth middleware" — gone in an hour without action
99
+ - No LLM call needed, pure recency-weighted retrieval
100
+
101
+ **Oracle agent** (refactored):
102
+ - Queries all three layers simultaneously
103
+ - Formats with explicit citations: `[episodic #3]`, `[fact #a2b1]`, `[working]`
104
+ - ACC-style bounded context: top 3 verbatim + tail compressed into a summary
105
+ - Layer conflict resolution (scratchpad beats working beats episodic)
106
+
107
+ **New capture paths** (Phase 2):
108
+ - `anamne journal` — timestamped entry, one command, no ceremony
109
+ - `anamne import-chat` — point at an exported Claude/ChatGPT JSON, extract durable facts
110
+
111
+ ---
112
+
113
+ ## The Design That Emerged
114
+
115
+ The thing I realized while implementing this: **the problem I'm solving is different from Repowise's.**
116
+
117
+ Repowise solves "why was this code written this way?" for teams. It's a knowledge management tool
118
+ for codebases.
119
+
120
+ ANAMNE solves "what do I know about everything I've worked on?" for individuals. It's a
121
+ personal memory layer that works across all your AI tools, all your projects, your preferences,
122
+ your constraints, your history.
123
+
124
+ Those are different markets. One is team-facing (requires enterprise sales, permission models,
125
+ onboarding). The other is individual-facing (one-command install, local-first, bring your own key).
126
+
127
+ The pivot didn't require rebuilding anything. It required reframing the problem.
128
+
129
+ ---
130
+
131
+ ## What the Code Looks Like
132
+
133
+ The Oracle agent — the core of the recall system — ends up surprisingly clean:
134
+
135
+ ```python
136
+ def ask(self, question: str, ...) -> str:
137
+ # Pull from all three layers
138
+ episodic = self._store.search(question, n_results=8)
139
+ facts = self._store.search_facts(question, limit=8)
140
+ working = self._store.working_active()[:10]
141
+
142
+ # ACT-R: update activation on retrieved facts
143
+ if facts:
144
+ self._store.touch_facts([f["id"] for f in facts])
145
+
146
+ # ACC: top-3 verbatim, tail compressed
147
+ verbatim = episodic[:3]
148
+ tail = episodic[3:]
149
+ compressed = self._compress_tail(tail, question) if tail else None
150
+
151
+ # Format with citations, send to LLM
152
+ prompt = _ORACLE_PROMPT.format(
153
+ working=self._format_working(working),
154
+ facts=self._format_facts(facts),
155
+ decisions=self._format_decisions(verbatim),
156
+ compressed_section=f"BACKGROUND: {compressed}\n\n" if compressed else "",
157
+ question=question,
158
+ )
159
+ return self._llm.complete(prompt, max_tokens=2048).text
160
+ ```
161
+
162
+ Every claim in the answer is cited back to its layer and entry. The LLM is instructed to surface
163
+ staleness warnings and call out conflicts between layers.
164
+
165
+ The consolidation step — analogous to sleep-phase memory consolidation in neuroscience — clusters
166
+ scratchpad facts by keyword overlap and merges each cluster via LLM:
167
+
168
+ ```bash
169
+ $ anamne consolidate --dry-run
170
+
171
+ Merge 1:
172
+ - I prefer Python for backend services
173
+ - I prefer Python over Go for scripting
174
+ -> Prefer Python over Go for all backend and scripting work
175
+
176
+ Merge 2:
177
+ - Database uses PostgreSQL
178
+ - Switched from MySQL to Postgres in 2024 for better JSON support
179
+ -> Using PostgreSQL (migrated from MySQL in 2024 for native JSON support)
180
+ ```
181
+
182
+ ---
183
+
184
+ ## What Surprised Me
185
+
186
+ **Reading papers was faster than searching for ideas.** The four papers I read took maybe three
187
+ hours total. They gave me a clear design vocabulary (episodic, semantic, working memory), specific
188
+ algorithms (ACT-R activation formula, ACC compression), and actual citations I can put in the README.
189
+
190
+ That's worth more than any "find a gap" exercise.
191
+
192
+ **The competitive landscape is a feature, not a bug.** Yes, Mem0 and Supermemory exist. They're
193
+ building cloud SDKs for developers. I'm building a local-first tool for individual AI users. The
194
+ fact that there's a funded market means people want this — I'm just serving a different slice of it.
195
+
196
+ **"Brain-inspired" is a useful metaphor, not a liability.** I was initially worried it would sound
197
+ like marketing fluff. But grounding it in actual papers — LIGHT, ACT-R, hippocampal indexing
198
+ theory — makes it defensible. When someone asks "why three layers?", I have a real answer.
199
+
200
+ ---
201
+
202
+ ## The Honest Assessment
203
+
204
+ ANAMNE is a personal portfolio project. It won't replace Mem0. It won't scale to teams.
205
+
206
+ What it is:
207
+ - A working CLI demo with cited recall across three memory layers
208
+ - A real MCP server (tested with Claude Code and Cursor)
209
+ - A brain-inspired memory architecture grounded in actual 2026 research papers
210
+ - An honest README that doesn't overclaim
211
+
212
+ What it demonstrates:
213
+ - The ability to read research papers and translate them into working code
214
+ - Rapid iteration under uncertainty (pivot in 48 hours, don't rebuild)
215
+ - Engineering judgment (scope-appropriate design, no overengineering)
216
+
217
+ The "build a thing, find a competitor, read papers, pivot" story is more interesting to a
218
+ hiring manager than "I built X, here is the feature list."
219
+
220
+ ---
221
+
222
+ ## What's Next
223
+
224
+ Phase 2 is already started:
225
+ - `anamne import-chat` — import exported Claude/ChatGPT conversations, extract facts
226
+ - `anamne journal` — one-command timestamped notes, no ceremony
227
+
228
+ The interesting open question is Phase 3: **ACT-R decay**. Right now "activation" is tracked
229
+ (last_used, use_count) but there's no actual decay formula. The real ACT-R formula is:
230
+
231
+ ```
232
+ activation = ln(Σ t_i^(-d)) + noise
233
+ ```
234
+
235
+ where `t_i` is the recency of each retrieval and `d` is the decay parameter. Implementing that
236
+ would make the "brain-inspired" claim genuinely precise rather than loosely metaphorical.
237
+
238
+ ---
239
+
240
+ ## Code
241
+
242
+ [github.com/venumittapalli576/anamne](https://github.com/venumittapalli576/anamne)
243
+
244
+ MIT license. One-command install. Bring your own key. Zero telemetry.
245
+
246
+ ```bash
247
+ pip install anamne
248
+ anamne init
249
+ ```
@@ -0,0 +1,122 @@
1
+ # Changelog
2
+
3
+ All notable changes to ANAMNE are documented here.
4
+
5
+ ---
6
+
7
+ ## [0.3.0] — 2026-05-10
8
+
9
+ ### Added — Phase 3 memory upgrades
10
+
11
+ **Semantic scratchpad search**
12
+ - Facts are now embedded into a dedicated ChromaDB `scratchpad` collection on write
13
+ - `search_facts_semantic()` — embedding-based search; finds conceptually related facts
14
+ even when exact keywords don't match (e.g. "database" finds "PostgreSQL" facts)
15
+ - `search_facts_ranked()` now merges substring + semantic candidates, deduplicates,
16
+ then re-ranks by ACT-R activation — best of both retrieval strategies
17
+ - One-time migration: existing facts are back-filled into ChromaDB on first startup
18
+ - `forget_fact()` now also deletes from ChromaDB scratchpad collection
19
+
20
+ **Incremental indexing**
21
+ - New `indexed_commits` SQL table tracks which commits have already been processed
22
+ - `is_commit_indexed()`, `mark_commit_indexed()`, `indexed_commit_count()` on store
23
+ - `HistorianAgent.index_repo(incremental=True)` skips already-indexed commits
24
+ - New CLI command: `anamne sync <repo>` — re-indexes only new commits,
25
+ saving API calls when you run it after `git pull` or `git commit`
26
+
27
+ **Auto-consolidation daemon**
28
+ - New CLI command: `anamne watch` — runs `consolidate` on a configurable schedule
29
+ (default: every 3600s). Background memory maintenance, analog of sleep-phase
30
+ consolidation in cognitive science. Press Ctrl+C to stop.
31
+
32
+ **New CLI commands** (search, export, capture-clipboard added in this release too)
33
+ - `anamne search <query>` — direct ACT-R-ranked scratchpad search, no API key needed
34
+ - `anamne export` — dump all memories to JSON or Markdown for backup/migration
35
+ - `anamne capture-clipboard` — read clipboard and save as scratchpad fact
36
+
37
+ ### Fixed
38
+ - `status` command: removed dead `ollama` reference in API key check
39
+ - `recall` and MCP `search_facts`: upgraded to `search_facts_ranked()` (was unranked)
40
+
41
+ ### Tests
42
+ - 41 tests total (was 31 → 34 → 41), all passing
43
+ - New: semantic search (3), incremental indexing (4), list_all_decisions (3)
44
+
45
+ ---
46
+
47
+ ## [0.2.0] — 2026-05-10
48
+
49
+ ### Changed (breaking)
50
+ - **Renamed**: project `provenance` → `anamne` (CLI command, package, data dir `~/.anamne`)
51
+ - **Removed**: Ollama support (local models too weak for structured JSON extraction tasks)
52
+ - **Removed**: dead FastAPI/uvicorn/jinja2 dependencies
53
+
54
+ ### Added — Memory architecture (LIGHT + ACC frameworks)
55
+ - **Three-layer memory** following the LIGHT framework (arXiv 2510.27246):
56
+ - *Episodic* — long-term decisions from git history (ChromaDB semantic search)
57
+ - *Scratchpad* — durable user-stated facts (SQLite, full-text search)
58
+ - *Working memory* — short-lived session context with TTL auto-expiry
59
+ - **ACT-R real decay formula**: `A_i = ln(Σ t_j^-d)` where `t_j` = seconds since retrieval `j`
60
+ - New `retrieval_log` SQL table — every fact access is timestamped
61
+ - `activation_score()` — computes true ACT-R base-level activation
62
+ - `search_facts_ranked()` — re-ranks search results by ACT-R activation
63
+ - **ACC bounded context compression**: top-3 episodic results verbatim, tail LLM-compressed
64
+ - **Fact consolidation** (`anamne consolidate`): Jaccard keyword clustering + LLM merge
65
+ - **Layer-conflict priority**: scratchpad > working > episodic (per LIGHT design)
66
+ - **Staleness flags**: episodic items with `valid_until` in the past show `[POTENTIALLY STALE]`
67
+
68
+ ### Added — CLI commands
69
+ | Command | Description |
70
+ |---|---|
71
+ | `anamne journal` | Timestamped scratchpad entry with auto `journal` tag |
72
+ | `anamne import-chat` | Extract durable facts from exported Claude / ChatGPT JSON |
73
+ | `anamne consolidate` | Merge redundant facts (Jaccard overlap + LLM) |
74
+ | `anamne search` | Direct scratchpad search, ACT-R ranked, no API key needed |
75
+ | `anamne export` | Backup all memories to JSON or Markdown |
76
+ | `anamne capture-clipboard` | Save clipboard text as a scratchpad fact |
77
+ | `anamne recall` | Cross-layer recall (upgraded to use ACT-R ranking) |
78
+
79
+ ### Added — MCP tools (11 total)
80
+ | Tool | Layer |
81
+ |---|---|
82
+ | `ask_why` | Cross-layer (Oracle) |
83
+ | `search_decisions` | Episodic |
84
+ | `get_file_context` | Episodic |
85
+ | `get_stats` | All |
86
+ | `remember` | Scratchpad |
87
+ | `list_facts` | Scratchpad |
88
+ | `forget_fact` | Scratchpad |
89
+ | `search_facts` | Scratchpad (ACT-R ranked) |
90
+ | `consolidate_facts` | Scratchpad |
91
+ | `working_memory_add` | Working |
92
+ | `working_memory_active` | Working |
93
+
94
+ ### Added — Infrastructure
95
+ - **Test suite** (31 tests, 100% pass):
96
+ - `tests/test_models.py` — Decision model, staleness, serialisation
97
+ - `tests/test_store.py` — all three memory layers + ACT-R activation
98
+ - `tests/test_clustering.py` — `_cluster_by_overlap` threshold behaviour
99
+ - **GitHub Actions CI** (`.github/workflows/ci.yml`) — runs on every push/PR
100
+ - **pyproject.toml**: authors, keywords, classifiers, project URLs, dev extras
101
+ - **LICENSE**: MIT, copyright Venu Mittapalli
102
+ - **BLOG_POST.md**: origin story and technical deep-dive
103
+
104
+ ### Fixed
105
+ - `status` command: removed dead `ollama` reference in API key check
106
+ - `recall` command: now uses `search_facts_ranked()` (was unranked)
107
+ - MCP `search_facts` tool: now uses `search_facts_ranked()` (was unranked)
108
+ - README, ROADMAP: all `provenance` references updated to `anamne`
109
+
110
+ ---
111
+
112
+ ## [0.1.0] — 2026-04 (internal)
113
+
114
+ First working version under the name `provenance`.
115
+
116
+ - `Decision` data model with bi-temporal fields
117
+ - SQLite + ChromaDB dual store
118
+ - Historian Agent — git history extraction via LLM
119
+ - Oracle Agent — recall with citations
120
+ - FastMCP server with 4 tools
121
+ - CLI: `init`, `index`, `ask`, `status`, `mcp-server`
122
+ - Claude + Gemini multi-model LLM client
anamne-0.3.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Venu Mittapalli
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.