memctrl 1.0.1__tar.gz → 1.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 (47) hide show
  1. {memctrl-1.0.1 → memctrl-1.1.0}/PKG-INFO +8 -11
  2. {memctrl-1.0.1 → memctrl-1.1.0}/README.md +7 -10
  3. {memctrl-1.0.1 → memctrl-1.1.0}/memctrl/__init__.py +1 -1
  4. {memctrl-1.0.1 → memctrl-1.1.0}/memctrl/cli.py +41 -3
  5. {memctrl-1.0.1 → memctrl-1.1.0}/memctrl/installer.py +6 -2
  6. {memctrl-1.0.1 → memctrl-1.1.0}/memctrl/rules.py +7 -0
  7. memctrl-1.1.0/memctrl/templates/SKILL.md +95 -0
  8. {memctrl-1.0.1 → memctrl-1.1.0}/pyproject.toml +1 -1
  9. memctrl-1.0.1/memctrl/templates/SKILL.md +0 -63
  10. {memctrl-1.0.1 → memctrl-1.1.0}/.env.example +0 -0
  11. {memctrl-1.0.1 → memctrl-1.1.0}/.github/workflows/ci.yml +0 -0
  12. {memctrl-1.0.1 → memctrl-1.1.0}/.github/workflows/publish.yml +0 -0
  13. {memctrl-1.0.1 → memctrl-1.1.0}/.gitignore +0 -0
  14. {memctrl-1.0.1 → memctrl-1.1.0}/.memoryrc.example +0 -0
  15. {memctrl-1.0.1 → memctrl-1.1.0}/ARTICLE.md +0 -0
  16. {memctrl-1.0.1 → memctrl-1.1.0}/DISTRIBUTION.md +0 -0
  17. {memctrl-1.0.1 → memctrl-1.1.0}/LICENSE +0 -0
  18. {memctrl-1.0.1 → memctrl-1.1.0}/Makefile +0 -0
  19. {memctrl-1.0.1 → memctrl-1.1.0}/PYPI_PUBLISH.md +0 -0
  20. {memctrl-1.0.1 → memctrl-1.1.0}/RELEASE_NOTES.md +0 -0
  21. {memctrl-1.0.1 → memctrl-1.1.0}/benchmarks/__init__.py +0 -0
  22. {memctrl-1.0.1 → memctrl-1.1.0}/benchmarks/retention_benchmark.py +0 -0
  23. {memctrl-1.0.1 → memctrl-1.1.0}/docs/index.html +0 -0
  24. {memctrl-1.0.1 → memctrl-1.1.0}/docs/memctrl_logo.png +0 -0
  25. {memctrl-1.0.1 → memctrl-1.1.0}/docs/memory-viz.html +0 -0
  26. {memctrl-1.0.1 → memctrl-1.1.0}/docs/signature-shot.html +0 -0
  27. {memctrl-1.0.1 → memctrl-1.1.0}/examples/__init__.py +0 -0
  28. {memctrl-1.0.1 → memctrl-1.1.0}/examples/coding_agent_demo.py +0 -0
  29. {memctrl-1.0.1 → memctrl-1.1.0}/examples/killer_demo.py +0 -0
  30. {memctrl-1.0.1 → memctrl-1.1.0}/examples/langgraph_integration.py +0 -0
  31. {memctrl-1.0.1 → memctrl-1.1.0}/memctrl/extractor.py +0 -0
  32. {memctrl-1.0.1 → memctrl-1.1.0}/memctrl/integrations/langgraph.py +0 -0
  33. {memctrl-1.0.1 → memctrl-1.1.0}/memctrl/mcp_server.py +0 -0
  34. {memctrl-1.0.1 → memctrl-1.1.0}/memctrl/retriever.py +0 -0
  35. {memctrl-1.0.1 → memctrl-1.1.0}/memctrl/store.py +0 -0
  36. {memctrl-1.0.1 → memctrl-1.1.0}/memctrl/templates/__init__.py +0 -0
  37. {memctrl-1.0.1 → memctrl-1.1.0}/memctrl/tree.py +0 -0
  38. {memctrl-1.0.1 → memctrl-1.1.0}/requirements.txt +0 -0
  39. {memctrl-1.0.1 → memctrl-1.1.0}/tests/__init__.py +0 -0
  40. {memctrl-1.0.1 → memctrl-1.1.0}/tests/fixtures/sample.memoryrc +0 -0
  41. {memctrl-1.0.1 → memctrl-1.1.0}/tests/fixtures/sample_session.txt +0 -0
  42. {memctrl-1.0.1 → memctrl-1.1.0}/tests/test_cli.py +0 -0
  43. {memctrl-1.0.1 → memctrl-1.1.0}/tests/test_extractor.py +0 -0
  44. {memctrl-1.0.1 → memctrl-1.1.0}/tests/test_retriever.py +0 -0
  45. {memctrl-1.0.1 → memctrl-1.1.0}/tests/test_rules.py +0 -0
  46. {memctrl-1.0.1 → memctrl-1.1.0}/tests/test_store.py +0 -0
  47. {memctrl-1.0.1 → memctrl-1.1.0}/tests/test_tree.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: memctrl
3
- Version: 1.0.1
3
+ Version: 1.1.0
4
4
  Summary: Cognitive Memory Runtime for AI Agents — hierarchical, explainable, and self-managing
5
5
  Author: MemCtrl Contributors
6
6
  License: MIT
@@ -150,15 +150,12 @@ Register the skill with your AI assistant:
150
150
 
151
151
  | Platform | Command |
152
152
  |---|---|
153
- | Claude Code | `memctrl install --platform claude` |
154
- | Codex | `memctrl install --platform codex` |
155
- | Cursor | `memctrl install --platform cursor` |
156
- | Kimi Code | `memctrl install --platform kimi` |
157
- | Gemini CLI | `memctrl install --platform gemini` |
158
- | Aider | `memctrl install --platform aider` |
159
- | VS Code Copilot Chat | `memctrl install --platform vscode` |
160
- | GitHub Copilot CLI | `memctrl install --platform copilot` |
161
- | Pi | `memctrl install --platform pi` |
153
+ | Claude Code | `memctrl install --tool claude_code` |
154
+ | Codex | `memctrl install --tool codex` |
155
+ | Cursor | `memctrl install --tool cursor` |
156
+ | Kimi Code | `memctrl install --tool kimi` |
157
+ | Pi | `memctrl install --tool pi` |
158
+ | AxGa | `memctrl install --tool axga` |
162
159
 
163
160
  Project-scoped install (commits into your repo):
164
161
 
@@ -263,7 +260,7 @@ MemCtrl is designed to plug into existing agent stacks:
263
260
  | Framework | Status | Notes |
264
261
  |---|---|---|
265
262
  | **MCP** | ✅ Ready | Stdio transport server included |
266
- | **Claude Code** | ✅ Ready | `memctrl install --platform claude` |
263
+ | **Claude Code** | ✅ Ready | `memctrl install --tool claude_code` |
267
264
  | **LangGraph** | ✅ Ready | `MemCtrlSaver` checkpoint + `MemoryNode` |
268
265
  | **CrewAI** | 🚧 Planned | Long-term memory backend |
269
266
  | **AutoGen** | 🚧 Planned | Agent memory provider |
@@ -125,15 +125,12 @@ Register the skill with your AI assistant:
125
125
 
126
126
  | Platform | Command |
127
127
  |---|---|
128
- | Claude Code | `memctrl install --platform claude` |
129
- | Codex | `memctrl install --platform codex` |
130
- | Cursor | `memctrl install --platform cursor` |
131
- | Kimi Code | `memctrl install --platform kimi` |
132
- | Gemini CLI | `memctrl install --platform gemini` |
133
- | Aider | `memctrl install --platform aider` |
134
- | VS Code Copilot Chat | `memctrl install --platform vscode` |
135
- | GitHub Copilot CLI | `memctrl install --platform copilot` |
136
- | Pi | `memctrl install --platform pi` |
128
+ | Claude Code | `memctrl install --tool claude_code` |
129
+ | Codex | `memctrl install --tool codex` |
130
+ | Cursor | `memctrl install --tool cursor` |
131
+ | Kimi Code | `memctrl install --tool kimi` |
132
+ | Pi | `memctrl install --tool pi` |
133
+ | AxGa | `memctrl install --tool axga` |
137
134
 
138
135
  Project-scoped install (commits into your repo):
139
136
 
@@ -238,7 +235,7 @@ MemCtrl is designed to plug into existing agent stacks:
238
235
  | Framework | Status | Notes |
239
236
  |---|---|---|
240
237
  | **MCP** | ✅ Ready | Stdio transport server included |
241
- | **Claude Code** | ✅ Ready | `memctrl install --platform claude` |
238
+ | **Claude Code** | ✅ Ready | `memctrl install --tool claude_code` |
242
239
  | **LangGraph** | ✅ Ready | `MemCtrlSaver` checkpoint + `MemoryNode` |
243
240
  | **CrewAI** | 🚧 Planned | Long-term memory backend |
244
241
  | **AutoGen** | 🚧 Planned | Agent memory provider |
@@ -4,7 +4,7 @@ Inspired by PageIndex's tree-based retrieval and Graphify's install pattern.
4
4
  Uses hierarchical reasoning (not vectors) for explainable memory retrieval.
5
5
  """
6
6
 
7
- __version__ = "1.0.1"
7
+ __version__ = "1.1.0"
8
8
 
9
9
  from memctrl.store import Memory, MemoryStore, TriggerLog, TreeNode
10
10
  from memctrl.retriever import RetrievalResult
@@ -37,11 +37,34 @@ console = Console()
37
37
 
38
38
 
39
39
  def _get_store():
40
- """Get MemoryStore instance with default DB path."""
40
+ """Get MemoryStore instance with project-local or global DB path."""
41
41
  from memctrl.store import MemoryStore
42
42
 
43
+ # 1. Environment variable overrides everything
43
44
  db_path = os.environ.get("MEMCTRL_DB_PATH")
44
- return MemoryStore(db_path)
45
+ if db_path:
46
+ return MemoryStore(db_path)
47
+
48
+ # 2. If .memoryrc exists in cwd, use its db_path
49
+ rc_path = Path(".memoryrc")
50
+ if rc_path.exists():
51
+ try:
52
+ from memctrl.rules import RuleEngine
53
+
54
+ engine = RuleEngine(str(rc_path))
55
+ rules = engine.load()
56
+ if rules.db_path:
57
+ # Resolve relative to .memoryrc location (cwd)
58
+ resolved = Path(rules.db_path)
59
+ if not resolved.is_absolute():
60
+ resolved = rc_path.parent / resolved
61
+ resolved.parent.mkdir(parents=True, exist_ok=True)
62
+ return MemoryStore(str(resolved))
63
+ except Exception:
64
+ pass # Fallback to global default
65
+
66
+ # 3. Global default
67
+ return MemoryStore()
45
68
 
46
69
 
47
70
  def _get_engine():
@@ -92,7 +115,7 @@ def install(
92
115
  def init(
93
116
  force: bool = typer.Option(False, help="Overwrite existing .memoryrc"),
94
117
  ):
95
- """Create .memoryrc in current directory"""
118
+ """Create .memoryrc and project-local database in current directory"""
96
119
  dest = Path(".memoryrc")
97
120
  if dest.exists() and not force:
98
121
  console.print(
@@ -109,6 +132,18 @@ def init(
109
132
  dest.write_text(content)
110
133
  console.print(f"[green]Created {dest}[/green]")
111
134
 
135
+ # Create project-local database directory and initialize empty DB
136
+ db_dir = Path(".memctrl")
137
+ db_dir.mkdir(parents=True, exist_ok=True)
138
+ db_path = db_dir / "memories.db"
139
+ if not db_path.exists():
140
+ from memctrl.store import MemoryStore
141
+
142
+ MemoryStore(str(db_path)) # initializes schema
143
+ console.print(f"[green]Created {db_path}[/green]")
144
+ else:
145
+ console.print(f"[dim]{db_path} already exists[/dim]")
146
+
112
147
 
113
148
  @app.command()
114
149
  def add(
@@ -464,6 +499,9 @@ def serve(
464
499
  def _default_memoryrc() -> str:
465
500
  return """# MemCtrl configuration
466
501
 
502
+ [memctrl]
503
+ db_path = ".memctrl/memories.db"
504
+
467
505
  [layers]
468
506
  project = "architecture decisions, tech stack, ADRs, why we chose X"
469
507
  session = "current task, WIP, what was done this session"
@@ -38,6 +38,10 @@ TOOL_PATHS = {
38
38
  "pi": [
39
39
  "~/.pi/agent/skills/memctrl/SKILL.md",
40
40
  ],
41
+ "kimi": [
42
+ "~/.kimi/skills/memctrl/SKILL.md",
43
+ ".kimi/skills/memctrl/SKILL.md",
44
+ ],
41
45
  }
42
46
 
43
47
 
@@ -66,7 +70,7 @@ def install_skill(
66
70
  """Install SKILL.md for specified tool or all detected tools.
67
71
 
68
72
  Args:
69
- tool: Specific tool name (claude_code, cursor, codex, etc.)
73
+ tool: Specific tool name (claude_code, cursor, codex, kimi, etc.)
70
74
  project: If True, install to project-level paths (e.g., .claude/)
71
75
  verbose: Print summary
72
76
 
@@ -118,6 +122,6 @@ def install_skill(
118
122
  for p in paths:
119
123
  print(f" {tool_name}: {p}")
120
124
  print("\nTo force install for a specific tool, use:")
121
- print(" memctrl install --tool claude_code")
125
+ print(" memctrl install --tool kimi")
122
126
 
123
127
  return installed_paths
@@ -43,6 +43,7 @@ class Rules:
43
43
  forget_never: List[str] = field(default_factory=list)
44
44
  forget_after_days: Dict[str, int] = field(default_factory=dict)
45
45
  confidence: Dict[str, float] = field(default_factory=dict)
46
+ db_path: Optional[str] = None
46
47
 
47
48
  def get_ttl_days(self, layer: str) -> Optional[int]:
48
49
  return self.forget_after_days.get(layer)
@@ -151,6 +152,12 @@ class RuleEngine:
151
152
  k: float(v) for k, v in extract["confidence"].items()
152
153
  }
153
154
 
155
+ # [memctrl]
156
+ if "memctrl" in data:
157
+ memctrl_cfg = data["memctrl"]
158
+ if "db_path" in memctrl_cfg:
159
+ rules.db_path = str(memctrl_cfg["db_path"])
160
+
154
161
  self.rules = rules
155
162
  return rules
156
163
 
@@ -0,0 +1,95 @@
1
+ ---
2
+ name: memctrl
3
+ description: |
4
+ MANDATORY: Before starting ANY work in this project, load context from
5
+ memctrl. After finishing work, store what was learned. This is the project's
6
+ cognitive memory layer — not optional.
7
+
8
+ CRITICAL RULES:
9
+ 1. ALWAYS run `memctrl query "current project context"` at session start
10
+ 2. ALWAYS run `memctrl add` after architecture decisions or discoveries
11
+ 3. ALWAYS run `memctrl trigger on_session_end` before ending session
12
+ 4. NEVER say "I don't remember" — query memctrl first
13
+ ---
14
+
15
+ # MemCtrl — Mandatory Memory Protocol
16
+
17
+ ## ⚡ Session Start Protocol (REQUIRED)
18
+
19
+ Run this **before** any coding, planning, or discussion:
20
+
21
+ ```bash
22
+ memctrl query "current project context"
23
+ memctrl query "what decisions have been made"
24
+ memctrl query "what is the tech stack"
25
+ ```
26
+
27
+ If no context exists (new project), initialize:
28
+ ```bash
29
+ memctrl init --force
30
+ ```
31
+
32
+ ## 📝 During Work — Store Automatically
33
+
34
+ After ANY of these events, run `memctrl add` **immediately**:
35
+
36
+ | Event | Example Command |
37
+ |-------|----------------|
38
+ | Architecture decision | `memctrl add "Using FastAPI + async SQLAlchemy" --layer project` |
39
+ | Bug discovered | `memctrl add "JWT validation fails on expired tokens — use jose` --layer project` |
40
+ | Tech choice | `memctrl add "Chose PostgreSQL over SQLite for concurrent writes" --layer project` |
41
+ | Current task | `memctrl add "Implementing OAuth2 login flow" --layer session` |
42
+ | User preference | `memctrl add "Prefers explicit types over generics" --layer user` |
43
+ | Refactoring | `memctrl add "Renamed UserService -> AuthService" --layer project` |
44
+
45
+ ## 🏁 Session End Protocol (REQUIRED)
46
+
47
+ Before ending ANY session:
48
+
49
+ ```bash
50
+ memctrl trigger on_session_end
51
+ memctrl audit
52
+ ```
53
+
54
+ This consolidates session memories and cleans up expired entries.
55
+
56
+ ## 🔍 When User Asks Context Questions
57
+
58
+ If user asks anything like:
59
+ - "Why did we choose X?"
60
+ - "What was the decision about Y?"
61
+ - "What were we doing last time?"
62
+ - "What's our tech stack?"
63
+
64
+ **NEVER guess.** Always run:
65
+ ```bash
66
+ memctrl query "<user's question>"
67
+ ```
68
+
69
+ ## 🧠 Memory Layers
70
+
71
+ | Layer | Purpose | When to Use | Expiry |
72
+ |-------|---------|-------------|--------|
73
+ | **project** | Architecture, ADRs, tech stack, refactors | Permanent decisions | Never |
74
+ | **session** | Current task, WIP, what was done today | Temporary work | 7 days |
75
+ | **user** | Preferences, coding style, patterns | Personal habits | 90 days |
76
+
77
+ ## 📋 Quick Commands
78
+
79
+ ```bash
80
+ memctrl query "<question>" # Retrieve with reasoning trace
81
+ memctrl add "<fact>" --layer project # Store permanent knowledge
82
+ memctrl add "<fact>" --layer session # Store temporary work
83
+ memctrl tree # View full memory hierarchy
84
+ memctrl trigger on_session_end # Consolidate & cleanup
85
+ memctrl audit # Review memory log
86
+ ```
87
+
88
+ ## 🌐 MCP Server (if running)
89
+
90
+ If `memctrl serve` is active, use these tools directly:
91
+ - `memctrl_query(query, layer?)` — Retrieve memories
92
+ - `memctrl_add(content, layer, source?)` — Store memory
93
+ - `memctrl_trigger(event, context?)` — Fire rule trigger
94
+ - `memctrl_tree()` — Get memory hierarchy
95
+ - `memctrl_audit(limit?)` — View audit log
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "memctrl"
3
- version = "1.0.1"
3
+ version = "1.1.0"
4
4
  description = "Cognitive Memory Runtime for AI Agents — hierarchical, explainable, and self-managing"
5
5
  readme = "README.md"
6
6
  license = {text = "MIT"}
@@ -1,63 +0,0 @@
1
- ---
2
- name: memctrl
3
- description: >
4
- Rule-governed memory layer for this project. Call memctrl to store,
5
- retrieve, or update memory about this project, session, or user preferences.
6
- Use this when:
7
- - Starting a new session (load context)
8
- - Making an architecture decision (store to project layer)
9
- - Finishing work (trigger on_session_end)
10
- - Asking "what did we decide about X" (query memory tree)
11
- ---
12
-
13
- # MemCtrl Memory System
14
-
15
- ## When to Use
16
-
17
- - **Session start**: Run `memctrl query "current project context"` for instant context
18
- - **Architecture decisions**: Run `memctrl add --layer project "decided to use X because Y"`
19
- - **Session end**: Run `memctrl trigger on_session_end` to consolidate memories
20
- - **Any context question**: Run `memctrl query "<your question>"`
21
-
22
- ## Memory Layers
23
-
24
- | Layer | Purpose | Default Expiry |
25
- |-------|---------|---------------|
26
- | project | Architecture decisions, tech stack, ADRs | Never |
27
- | session | Current task, WIP, what was done this session | 7 days |
28
- | user | Personal preferences, working style, patterns | 90 days |
29
-
30
- ## Key Commands
31
-
32
- ```bash
33
- # Query what you need
34
- memctrl query "what is our tech stack?"
35
- memctrl query "why did we choose PostgreSQL?"
36
-
37
- # Store decisions
38
- memctrl add "decided to use Firecracker for sandbox isolation" --layer project
39
- memctrl add "currently implementing auth flow" --layer session
40
- memctrl add "prefers async Python, minimal abstractions" --layer user
41
-
42
- # Manage
43
- memctrl tree # view full memory tree
44
- memctrl trigger on_session_end # consolidate session memories
45
- memctrl audit # review what was remembered/forgotten
46
- ```
47
-
48
- ## How Retrieval Works
49
-
50
- MemCtrl uses tree-based reasoning (like PageIndex) instead of vector similarity:
51
- - Memories are organized in a semantic tree: project/tech_stack/database
52
- - When you query, the system reasons about which branches to explore
53
- - Results include a trace: root → project → tech_stack → database
54
- - No embeddings needed — pure structured reasoning
55
-
56
- ## MCP Server
57
-
58
- If the MCP server is running (`memctrl serve`), these tools are available:
59
- - `memctrl_query(query, layer?)` → Retrieve memories with trace
60
- - `memctrl_add(content, layer, source?)` → Store a memory
61
- - `memctrl_trigger(event, context?)` → Fire a trigger
62
- - `memctrl_tree()` → Get full memory tree
63
- - `memctrl_audit(limit?)` → View audit log
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes