devmemory 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.
Files changed (41) hide show
  1. devmemory-0.1.0/.cursor/rules/devmemory-context.mdc +16 -0
  2. devmemory-0.1.0/.cursor/rules/devmemory.mdc +203 -0
  3. devmemory-0.1.0/.env.example +13 -0
  4. devmemory-0.1.0/.github/workflows/ci.yml +32 -0
  5. devmemory-0.1.0/.gitignore +20 -0
  6. devmemory-0.1.0/CHANGELOG.md +12 -0
  7. devmemory-0.1.0/CONTRIBUTING.md +45 -0
  8. devmemory-0.1.0/LICENSE +22 -0
  9. devmemory-0.1.0/Makefile +28 -0
  10. devmemory-0.1.0/PKG-INFO +383 -0
  11. devmemory-0.1.0/README.md +351 -0
  12. devmemory-0.1.0/devmemory/__init__.py +2 -0
  13. devmemory-0.1.0/devmemory/cli.py +99 -0
  14. devmemory-0.1.0/devmemory/commands/__init__.py +1 -0
  15. devmemory-0.1.0/devmemory/commands/add.py +160 -0
  16. devmemory-0.1.0/devmemory/commands/config_cmd.py +44 -0
  17. devmemory-0.1.0/devmemory/commands/context.py +285 -0
  18. devmemory-0.1.0/devmemory/commands/install.py +200 -0
  19. devmemory-0.1.0/devmemory/commands/learn.py +216 -0
  20. devmemory-0.1.0/devmemory/commands/search.py +245 -0
  21. devmemory-0.1.0/devmemory/commands/status.py +71 -0
  22. devmemory-0.1.0/devmemory/commands/sync.py +125 -0
  23. devmemory-0.1.0/devmemory/core/__init__.py +1 -0
  24. devmemory-0.1.0/devmemory/core/ams_client.py +113 -0
  25. devmemory-0.1.0/devmemory/core/config.py +42 -0
  26. devmemory-0.1.0/devmemory/core/git_ai_parser.py +362 -0
  27. devmemory-0.1.0/devmemory/core/llm_client.py +119 -0
  28. devmemory-0.1.0/devmemory/core/memory_formatter.py +445 -0
  29. devmemory-0.1.0/devmemory/core/sync_state.py +41 -0
  30. devmemory-0.1.0/devmemory/hooks/__init__.py +1 -0
  31. devmemory-0.1.0/devmemory/hooks/post_commit.py +6 -0
  32. devmemory-0.1.0/devmemory/rules/devmemory-context.mdc +16 -0
  33. devmemory-0.1.0/devmemory/rules/devmemory.mdc +203 -0
  34. devmemory-0.1.0/docker-compose.yml +89 -0
  35. devmemory-0.1.0/pyproject.toml +55 -0
  36. devmemory-0.1.0/scripts/install.sh +172 -0
  37. devmemory-0.1.0/scripts/verify.sh +180 -0
  38. devmemory-0.1.0/tests/test_git_ai_parser.py +49 -0
  39. devmemory-0.1.0/tests/test_learn.py +33 -0
  40. devmemory-0.1.0/tests/test_llm_client.py +38 -0
  41. devmemory-0.1.0/tests/test_memory_formatter.py +75 -0
@@ -0,0 +1,16 @@
1
+ ---
2
+ description: Auto-generated project context from DevMemory
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # DevMemory Auto-Context
7
+
8
+ If `.devmemory/CONTEXT.md` exists, **read it at the start of every task**.
9
+ It contains a pre-built briefing with relevant architecture decisions,
10
+ known gotchas, and coordination state for your current work area.
11
+
12
+ Run `devmemory context` in the terminal to refresh it before starting work.
13
+
14
+ This file is auto-generated based on the current git branch, changed files,
15
+ and recent commits. It complements — but does not replace — deeper searches
16
+ via `search_long_term_memory()` through MCP when you need specific answers.
@@ -0,0 +1,203 @@
1
+ ---
2
+ description: DevMemory agent coordination — shared persistent memory across sessions and agents
3
+ alwaysApply: true
4
+ ---
5
+
6
+ # DevMemory: Shared Agent Memory
7
+
8
+ You have access to a shared project memory via the `agent-memory` MCP server.
9
+ This memory persists across all sessions and is shared between every agent working on this project.
10
+ Use it as a **knowledgebase** (look up past decisions) and **coordination tool** (leave context for future sessions).
11
+
12
+ The project also maintains **knowledge files** in `.devmemory/knowledge/*.md` — these are the canonical source of architecture decisions, conventions, and gotchas. You are responsible for keeping them up to date.
13
+
14
+ ## 1. Before Starting Any Task
15
+
16
+ **Always search memory first.** Before writing code, look up what's already known:
17
+
18
+ ```
19
+ search_long_term_memory(text="<describe what you're about to work on>")
20
+ ```
21
+
22
+ Search for:
23
+ - Past decisions related to your task
24
+ - Known issues or gotchas in the area you're touching
25
+ - Established patterns and conventions
26
+ - Previous attempts that failed and why
27
+
28
+ If your task involves a specific file or module, also search for it:
29
+ ```
30
+ search_long_term_memory(text="<module or file name> issues and patterns")
31
+ ```
32
+
33
+ Also **read the relevant knowledge files** before starting:
34
+ - `.devmemory/knowledge/architecture.md` — architecture decisions and design rationale
35
+ - `.devmemory/knowledge/gotchas.md` — known issues, workarounds, and pitfalls
36
+ - Any other `.md` files in `.devmemory/knowledge/` relevant to your task
37
+
38
+ Incorporate any relevant context into your approach. If a previous session already tried and rejected an approach, don't repeat it.
39
+
40
+ ## 2. After Making Significant Decisions
41
+
42
+ You have two ways to persist knowledge, use the right one:
43
+
44
+ ### Quick capture: `devmemory add` (CLI)
45
+
46
+ For a single discovery or decision during a session, run:
47
+ ```bash
48
+ devmemory add "<what you learned>" --topic <topic> --entity <entity>
49
+ ```
50
+
51
+ Use this for:
52
+ - A gotcha you just hit and solved
53
+ - An API quirk you discovered mid-task
54
+ - A quick decision that doesn't need a full write-up
55
+
56
+ ### Structured knowledge: update `.devmemory/knowledge/` files
57
+
58
+ For anything that future agents should know about, **update the knowledge files directly** and then sync:
59
+
60
+ **When to update knowledge files:**
61
+ - You made an architecture decision (add to `architecture.md`)
62
+ - You discovered a gotcha or workaround (add to `gotchas.md`)
63
+ - You established a new convention or pattern (add to `conventions.md` — create if needed)
64
+ - You added/changed a major dependency and why
65
+ - You fixed a non-obvious bug that could regress
66
+
67
+ **How to update:**
68
+ 1. Edit the appropriate `.devmemory/knowledge/*.md` file (or create a new one)
69
+ 2. Add a new `## Section Heading` with the content
70
+ 3. Run `devmemory learn` to sync the updated files into the memory store
71
+
72
+ **Format for knowledge files:**
73
+ ```markdown
74
+ ---
75
+ topics: [architecture, decisions]
76
+ entities: [Redis, AMS]
77
+ ---
78
+
79
+ ## Section Title
80
+ Content explaining what, why, and any relevant details.
81
+ Each ## section becomes a separate searchable memory.
82
+ ```
83
+
84
+ **If no existing file fits, create a new one.** Good filenames:
85
+ - `architecture.md` — why we chose X over Y, system design
86
+ - `gotchas.md` — things that break if you're not careful
87
+ - `conventions.md` — coding patterns and project rules
88
+ - `api-notes.md` — external API quirks and limitations
89
+ - `dependencies.md` — why we use specific libraries
90
+
91
+ ### Also store via MCP for immediate availability
92
+
93
+ After updating knowledge files, also store via MCP so the memory is searchable immediately (before the next `devmemory learn` run):
94
+
95
+ ```
96
+ create_long_term_memories(memories=[{
97
+ "text": "<what was decided and why>",
98
+ "memory_type": "semantic",
99
+ "topics": ["<relevant>", "<topics>"],
100
+ "entities": ["<technologies>", "<modules>"]
101
+ }])
102
+ ```
103
+
104
+ ### What to store as memories
105
+
106
+ | Store | Don't store |
107
+ |-------|-------------|
108
+ | Architecture decisions with rationale | Implementation details obvious from code |
109
+ | Known gotchas and workarounds | Temporary debugging notes |
110
+ | Bug root causes and how they were fixed | Things that change every commit |
111
+ | Project conventions and patterns | Redundant copies of commit messages |
112
+ | API quirks and limitations discovered | Personal preferences |
113
+ | Why approach A was chosen over B | Simple variable renames or formatting |
114
+
115
+ ## 3. Keeping Knowledge Files Fresh
116
+
117
+ **This is a core responsibility.** Treat `.devmemory/knowledge/` files like living documentation.
118
+
119
+ ### During every session, ask yourself:
120
+
121
+ 1. **Did I discover something non-obvious?** → Add to `gotchas.md`
122
+ 2. **Did I make a design choice between alternatives?** → Add to `architecture.md`
123
+ 3. **Did I establish or follow a pattern?** → Add to `conventions.md` (create if missing)
124
+ 4. **Is any existing knowledge file outdated?** → Update it
125
+
126
+ ### After updating knowledge files:
127
+
128
+ Always run the sync to push changes into the memory store:
129
+ ```bash
130
+ devmemory learn
131
+ ```
132
+
133
+ ### Periodic review
134
+
135
+ If the session involved significant work (new features, refactors, bug fixes), review the knowledge files before finishing:
136
+ - Read through `.devmemory/knowledge/` files you touched or that relate to your work
137
+ - Update anything that's now wrong or incomplete
138
+ - Add sections for new knowledge gained during the session
139
+ - Run `devmemory learn` to sync
140
+
141
+ ## 4. Memory Types
142
+
143
+ Use **`semantic`** for timeless facts and decisions:
144
+ - Project conventions, architecture choices, API quirks
145
+ - These answer "how do we do X?" and "why did we choose Y?"
146
+
147
+ Use **`episodic`** for time-bound events (include `event_date`):
148
+ - Migrations, incidents, major refactors
149
+ - These answer "what happened?" and "when did we change X?"
150
+
151
+ ## 5. Session Coordination
152
+
153
+ Use working memory to coordinate across active sessions:
154
+
155
+ **At session start** — check if another session left context:
156
+ ```
157
+ get_working_memory(session_id="project-coordination")
158
+ ```
159
+
160
+ **When starting a large task** — announce what you're working on:
161
+ ```
162
+ set_working_memory(
163
+ session_id="project-coordination",
164
+ memories=[{
165
+ "text": "Currently refactoring the search command to add LLM synthesis",
166
+ "memory_type": "semantic",
167
+ "topics": ["active-work"]
168
+ }]
169
+ )
170
+ ```
171
+
172
+ **When finishing** — clear or update the coordination state.
173
+
174
+ ## 6. Search Before You Reinvent
175
+
176
+ If you're about to:
177
+ - Add a new dependency → search if there's a reason we use something else
178
+ - Change an API pattern → search for conventions
179
+ - Fix a bug → search if it was fixed before and regressed
180
+ - Refactor a module → search for known issues and design decisions
181
+
182
+ The 30 seconds spent searching can save hours of rediscovering what a previous session already learned.
183
+
184
+ ## 7. Summary: The Knowledge Loop
185
+
186
+ ```
187
+ Session Start
188
+ ├─ Run: devmemory context (generates .devmemory/CONTEXT.md briefing)
189
+ ├─ Read .devmemory/CONTEXT.md for pre-built context
190
+ ├─ search_long_term_memory(text="<your task>") for deeper dives
191
+ ├─ Read relevant .devmemory/knowledge/*.md files
192
+ └─ get_working_memory(session_id="project-coordination")
193
+
194
+ During Work
195
+ ├─ Hit a gotcha? → devmemory add "..." or update gotchas.md
196
+ ├─ Made a decision? → update architecture.md
197
+ └─ Established a pattern? → update conventions.md
198
+
199
+ Session End
200
+ ├─ Review and update .devmemory/knowledge/ files
201
+ ├─ devmemory learn (sync knowledge files to memory store)
202
+ └─ Update working memory coordination state
203
+ ```
@@ -0,0 +1,13 @@
1
+ OPENAI_API_KEY=your_openai_api_key_here
2
+
3
+ # Optional: override default models
4
+ # GENERATION_MODEL=gpt-5-mini
5
+ # EMBEDDING_MODEL=text-embedding-3-small
6
+
7
+ # Optional: use Anthropic instead of OpenAI for generation
8
+ # ANTHROPIC_API_KEY=your_anthropic_api_key_here
9
+ # GENERATION_MODEL=claude-3-5-haiku-20241022
10
+
11
+ # Note: OPENAI_API_KEY and GENERATION_MODEL are used by both the Docker
12
+ # services (AMS/MCP) and the CLI search command for answer synthesis.
13
+ # The CLI will auto-detect these from this .env file or environment variables.
@@ -0,0 +1,32 @@
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.10", "3.11", "3.12"]
15
+
16
+ steps:
17
+ - name: Checkout
18
+ uses: actions/checkout@v4
19
+
20
+ - name: Set up Python
21
+ uses: actions/setup-python@v5
22
+ with:
23
+ python-version: ${{ matrix.python-version }}
24
+
25
+ - name: Install dependencies
26
+ run: |
27
+ python -m pip install --upgrade pip
28
+ pip install -e .[dev]
29
+
30
+ - name: Run tests
31
+ run: pytest
32
+
@@ -0,0 +1,20 @@
1
+ .env
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+ *.egg-info/
6
+ dist/
7
+ build/
8
+ *.egg
9
+ .venv/
10
+ venv/
11
+ *.so
12
+ .mypy_cache/
13
+ .ruff_cache/
14
+ .pytest_cache/
15
+ redis_data/
16
+ redisinsight_data/
17
+ *.log
18
+ .DS_Store
19
+ .devmemory/CONTEXT.md
20
+ .devmemory/knowledge/*
@@ -0,0 +1,12 @@
1
+ ## Changelog
2
+
3
+ ### 0.1.0
4
+
5
+ - Initial public release of DevMemory.
6
+ - Sync AI coding context from Git AI to Redis Agent Memory Server.
7
+ - Three-layer memory formatting (commit summaries, per-file code, prompt-level context).
8
+ - Knowledge files in `.devmemory/knowledge/*.md` with `devmemory learn`.
9
+ - LLM-synthesized answers for `devmemory search`.
10
+ - Git hooks for automatic sync and context generation.
11
+ - Cursor MCP integration and agent rules for shared memory.
12
+
@@ -0,0 +1,45 @@
1
+ ## Contributing to DevMemory
2
+
3
+ ### Development setup
4
+
5
+ - Clone the repository and create a virtualenv.
6
+ - Copy `.env.example` to `.env` and set `OPENAI_API_KEY`.
7
+ - Start the local stack with `make up`.
8
+ - Install the package in editable mode with dev extras:
9
+
10
+ ```bash
11
+ pip install -e .[dev]
12
+ ```
13
+
14
+ ### Running tests and linting
15
+
16
+ - Run tests with:
17
+
18
+ ```bash
19
+ pytest
20
+ ```
21
+
22
+ - Run Ruff linting (optional) with:
23
+
24
+ ```bash
25
+ ruff check .
26
+ ```
27
+
28
+ ### Code style and guidelines
29
+
30
+ - Use type hints throughout new code.
31
+ - Keep dependencies minimal and aligned with existing stack (typer, httpx, rich).
32
+ - Follow the existing command structure:
33
+ - CLI entry points in `devmemory/cli.py`.
34
+ - Command implementations in `devmemory/commands/<name>.py` with `run_<name>()`.
35
+ - Core logic in `devmemory/core/`.
36
+
37
+ ### Proposing changes
38
+
39
+ - Open an issue describing the problem or feature.
40
+ - For pull requests:
41
+ - Create a topic branch from `main`.
42
+ - Add or update tests when changing behavior.
43
+ - Ensure `pytest` passes locally.
44
+ - Keep commits focused and descriptive.
45
+
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 DevMemory
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.
22
+
@@ -0,0 +1,28 @@
1
+ .PHONY: up down logs verify debug clean setup build publish
2
+
3
+ up:
4
+ docker compose up -d
5
+
6
+ down:
7
+ docker compose down
8
+
9
+ logs:
10
+ docker compose logs -f
11
+
12
+ verify:
13
+ @bash scripts/verify.sh
14
+
15
+ debug:
16
+ docker compose --profile debug up -d
17
+
18
+ clean:
19
+ docker compose down -v
20
+
21
+ setup:
22
+ @bash scripts/install.sh
23
+
24
+ build:
25
+ .venv/bin/python -m build
26
+
27
+ publish:
28
+ .venv/bin/twine upload dist/*