claudecode-memanto 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 (28) hide show
  1. claudecode_memanto-0.1.0/.gitignore +106 -0
  2. claudecode_memanto-0.1.0/CLAUDE.md +35 -0
  3. claudecode_memanto-0.1.0/PKG-INFO +90 -0
  4. claudecode_memanto-0.1.0/README.md +58 -0
  5. claudecode_memanto-0.1.0/assets/component-architecture.png +0 -0
  6. claudecode_memanto-0.1.0/assets/how-it-works-three-real-lifecycle-hooks.png +0 -0
  7. claudecode_memanto-0.1.0/claudecode_memanto/__init__.py +28 -0
  8. claudecode_memanto-0.1.0/claudecode_memanto/cli.py +156 -0
  9. claudecode_memanto-0.1.0/claudecode_memanto/client.py +229 -0
  10. claudecode_memanto-0.1.0/claudecode_memanto/config.py +95 -0
  11. claudecode_memanto-0.1.0/claudecode_memanto/extractor.py +238 -0
  12. claudecode_memanto-0.1.0/claudecode_memanto/installer.py +241 -0
  13. claudecode_memanto-0.1.0/claudecode_memanto/profile.py +145 -0
  14. claudecode_memanto-0.1.0/claudecode_memanto/skill_map.py +116 -0
  15. claudecode_memanto-0.1.0/hooks/__init__.py +1 -0
  16. claudecode_memanto-0.1.0/hooks/_common.py +233 -0
  17. claudecode_memanto-0.1.0/hooks/on_prompt.py +62 -0
  18. claudecode_memanto-0.1.0/hooks/on_stop.py +64 -0
  19. claudecode_memanto-0.1.0/hooks/session_start.py +44 -0
  20. claudecode_memanto-0.1.0/pyproject.toml +95 -0
  21. claudecode_memanto-0.1.0/tests/__init__.py +0 -0
  22. claudecode_memanto-0.1.0/tests/conftest.py +126 -0
  23. claudecode_memanto-0.1.0/tests/test_client.py +163 -0
  24. claudecode_memanto-0.1.0/tests/test_extractor.py +98 -0
  25. claudecode_memanto-0.1.0/tests/test_hooks.py +174 -0
  26. claudecode_memanto-0.1.0/tests/test_installer.py +127 -0
  27. claudecode_memanto-0.1.0/tests/test_profile.py +73 -0
  28. claudecode_memanto-0.1.0/tests/test_skill_map.py +49 -0
@@ -0,0 +1,106 @@
1
+ # Environment variables and secrets
2
+ .env
3
+ .env.local
4
+ .env.*.local
5
+ *.key
6
+ *.pem
7
+ *.crt
8
+ secrets/
9
+ .secrets
10
+
11
+ # Python
12
+ __pycache__/
13
+ *.py[cod]
14
+ *$py.class
15
+ *.so
16
+ .Python
17
+ uv.lock
18
+ build/
19
+ develop-eggs/
20
+ dist/
21
+ downloads/
22
+ eggs/
23
+ .eggs/
24
+ lib/
25
+ lib64/
26
+ parts/
27
+ sdist/
28
+ var/
29
+ wheels/
30
+ share/python-wheels/
31
+ *.egg-info/
32
+ .installed.cfg
33
+ *.egg
34
+ MANIFEST
35
+
36
+ # Virtual environments
37
+ venv/
38
+ .venv/
39
+ ENV/
40
+ env/
41
+ .env/
42
+
43
+ # IDEs
44
+ .vscode/
45
+ .idea/
46
+ .claude/
47
+ *.swp
48
+ *.swo
49
+ *~
50
+ .DS_Store
51
+
52
+ # Testing
53
+ .tox/
54
+ .nox/
55
+ .coverage
56
+ .coverage.*
57
+ .cache
58
+ nosetests.xml
59
+ coverage.xml
60
+ *.cover
61
+ *.log
62
+ .pytest_cache/
63
+
64
+ # Jupyter Notebook
65
+ .ipynb_checkpoints
66
+
67
+ # mypy
68
+ .mypy_cache/
69
+ .dmypy.json
70
+ dmypy.json
71
+
72
+ # Pyre type checker
73
+ .pyre/
74
+
75
+ # pytype static type analyzer
76
+ .pytype/
77
+
78
+ # Cython debug symbols
79
+ cython_debug/
80
+
81
+ # Database
82
+ *.db
83
+ *.sqlite
84
+ *.sqlite3
85
+
86
+ # Logs
87
+ logs/
88
+ *.log
89
+ pip-log.txt
90
+ pip-delete-this-directory.txt
91
+
92
+ # OS
93
+ .DS_Store
94
+ Thumbs.db
95
+ Desktop.ini
96
+
97
+ # Temporary files
98
+ tmp/
99
+ temp/
100
+ *.tmp
101
+ *.bak
102
+ *.swp
103
+ *.swo
104
+
105
+ # Generated version file
106
+ **/_version.py
@@ -0,0 +1,35 @@
1
+ ## Memanto Memory
2
+
3
+ Before running ANY skill, always execute:
4
+
5
+ ```bash
6
+ claudecode-memanto recall <skill-name> --hint "<brief task description>"
7
+ ```
8
+
9
+ Read the output carefully. It contains your persistent engineering profile:
10
+ - `[instruction]` entries are **hard rules** — always follow them, no exceptions
11
+ - `[decision]` entries are **past choices** — do not re-ask or re-litigate them
12
+ - `[preference]` entries are **style choices** — honour them unless technically impossible
13
+
14
+ If no memories are returned, proceed normally.
15
+
16
+ After completing ANY skill, ask the user:
17
+ > "Anything from this session worth saving to your engineering profile?"
18
+
19
+ If yes, run:
20
+
21
+ ```bash
22
+ claudecode-memanto store <skill-name> "<insight>" --type <type>
23
+ ```
24
+
25
+ Where `<type>` is one of: `instruction`, `decision`, `preference`, `learning`, `fact`, `artifact`, `goal`.
26
+
27
+ ### Available commands
28
+
29
+ ```bash
30
+ claudecode-memanto recall <skill> [--hint TEXT] [--limit N]
31
+ claudecode-memanto store <skill> "<summary>" [--type TYPE] [--confidence 0.0-1.0]
32
+ claudecode-memanto store-file <skill> <path> [--split]
33
+ claudecode-memanto profile
34
+ claudecode-memanto clear-agent
35
+ ```
@@ -0,0 +1,90 @@
1
+ Metadata-Version: 2.4
2
+ Name: claudecode-memanto
3
+ Version: 0.1.0
4
+ Summary: Cross-session engineering memory for Claude Code + mattpocock/skills, powered by Memanto. Real lifecycle hooks + LLM distillation = zero repeated instructions.
5
+ Project-URL: Homepage, https://www.memanto.ai
6
+ Project-URL: Documentation, https://docs.memanto.ai
7
+ Project-URL: Repository, https://github.com/moorcheh-ai/memanto
8
+ Project-URL: Bug Tracker, https://github.com/moorcheh-ai/memanto/issues
9
+ Author-email: Memanto <info@memanto.ai>
10
+ License: MIT
11
+ Keywords: agent memory,anthropic,claude,claude-code,hooks,mattpocock,memanto,moorcheh,semantic memory,skills
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Environment :: Console
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.10
19
+ Classifier: Programming Language :: Python :: 3.11
20
+ Classifier: Programming Language :: Python :: 3.12
21
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
22
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
23
+ Requires-Python: <4,>=3.10
24
+ Requires-Dist: memanto>=0.1.0
25
+ Requires-Dist: python-dotenv>=1.0.0
26
+ Provides-Extra: dev
27
+ Requires-Dist: mypy<2,>=1.10.0; extra == 'dev'
28
+ Requires-Dist: pytest-mock<4,>=3.12.0; extra == 'dev'
29
+ Requires-Dist: pytest<9,>=8.2.0; extra == 'dev'
30
+ Requires-Dist: ruff<0.15,>=0.14.6; extra == 'dev'
31
+ Description-Content-Type: text/markdown
32
+
33
+ # Claude Code + Memanto Integration
34
+
35
+ This package provides native integration of [Memanto's](https://memanto.ai) persistent, cross-session memory capabilities into [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview) and the [`mattpocock/skills`](https://github.com/mattpocock/skills) ecosystem.
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ pip install claudecode-memanto
41
+ ```
42
+
43
+ ![How it works](./assets/how-it-works-three-real-lifecycle-hooks.png)
44
+
45
+ ### Component architecture
46
+
47
+ ![Component architecture](./assets/component-architecture.png)
48
+
49
+ ## Features
50
+
51
+ - **Global Lifecycle Hooks**: Automatically inject memory context and distill sessions into persistent storage without modifying any skills.
52
+ - **Prompt Injection**: Use the CLI inside `CLAUDE.md` to instruct the agent to retrieve and store memories itself.
53
+ - **Zero Repeated Instructions**: Your architectural choices, codebase quirks, and coding preferences persist across terminal sessions.
54
+
55
+ ## Usage
56
+
57
+ ### Method 1: Lifecycle Hooks (Recommended)
58
+
59
+ Install the global lifecycle hooks into your Claude Code settings. This automatically injects context (`UserPromptExpansion`) and extracts durable decisions after execution (`Stop`) without requiring the agent to run manual CLI commands.
60
+
61
+ ```bash
62
+ # Register hooks locally (.claude/settings.json)
63
+ claudecode-memanto install
64
+
65
+ # Or globally (~/.claude/settings.json)
66
+ claudecode-memanto install --global
67
+ ```
68
+
69
+ Ensure `MOORCHEH_API_KEY` is set in your environment. Run any skill (e.g., `/tdd`) and Claude Code will automatically recall relevant engineering memories.
70
+
71
+ ### Method 2: Prompt Injection (Explicit)
72
+
73
+ If you prefer explicit control and want the agent to use tools rather than hidden hooks, you can use prompt injection via your `CLAUDE.md` file.
74
+
75
+ Install the prompt injection instructions into your global `~/.claude/CLAUDE.md` file (or your project-local `.claude/CLAUDE.md`). This provides Claude with the explicit instructions to run the CLI:
76
+
77
+ ```bash
78
+ # Append instructions to your local .claude/CLAUDE.md
79
+ claudecode-memanto install --method prompt
80
+
81
+ # Or append globally to ~/.claude/CLAUDE.md
82
+ claudecode-memanto install --method prompt --global
83
+ ```
84
+
85
+ ## Configuration
86
+
87
+ You can configure the integration via environment variables:
88
+ - `MOORCHEH_API_KEY`: Required. Your API key.
89
+ - `MEMANTO_AGENT_ID`: Set a custom agent ID namespace.
90
+ - `MEMANTO_RECALL_LIMIT`: Max memories to inject (default: 15).
@@ -0,0 +1,58 @@
1
+ # Claude Code + Memanto Integration
2
+
3
+ This package provides native integration of [Memanto's](https://memanto.ai) persistent, cross-session memory capabilities into [Claude Code](https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview) and the [`mattpocock/skills`](https://github.com/mattpocock/skills) ecosystem.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ pip install claudecode-memanto
9
+ ```
10
+
11
+ ![How it works](./assets/how-it-works-three-real-lifecycle-hooks.png)
12
+
13
+ ### Component architecture
14
+
15
+ ![Component architecture](./assets/component-architecture.png)
16
+
17
+ ## Features
18
+
19
+ - **Global Lifecycle Hooks**: Automatically inject memory context and distill sessions into persistent storage without modifying any skills.
20
+ - **Prompt Injection**: Use the CLI inside `CLAUDE.md` to instruct the agent to retrieve and store memories itself.
21
+ - **Zero Repeated Instructions**: Your architectural choices, codebase quirks, and coding preferences persist across terminal sessions.
22
+
23
+ ## Usage
24
+
25
+ ### Method 1: Lifecycle Hooks (Recommended)
26
+
27
+ Install the global lifecycle hooks into your Claude Code settings. This automatically injects context (`UserPromptExpansion`) and extracts durable decisions after execution (`Stop`) without requiring the agent to run manual CLI commands.
28
+
29
+ ```bash
30
+ # Register hooks locally (.claude/settings.json)
31
+ claudecode-memanto install
32
+
33
+ # Or globally (~/.claude/settings.json)
34
+ claudecode-memanto install --global
35
+ ```
36
+
37
+ Ensure `MOORCHEH_API_KEY` is set in your environment. Run any skill (e.g., `/tdd`) and Claude Code will automatically recall relevant engineering memories.
38
+
39
+ ### Method 2: Prompt Injection (Explicit)
40
+
41
+ If you prefer explicit control and want the agent to use tools rather than hidden hooks, you can use prompt injection via your `CLAUDE.md` file.
42
+
43
+ Install the prompt injection instructions into your global `~/.claude/CLAUDE.md` file (or your project-local `.claude/CLAUDE.md`). This provides Claude with the explicit instructions to run the CLI:
44
+
45
+ ```bash
46
+ # Append instructions to your local .claude/CLAUDE.md
47
+ claudecode-memanto install --method prompt
48
+
49
+ # Or append globally to ~/.claude/CLAUDE.md
50
+ claudecode-memanto install --method prompt --global
51
+ ```
52
+
53
+ ## Configuration
54
+
55
+ You can configure the integration via environment variables:
56
+ - `MOORCHEH_API_KEY`: Required. Your API key.
57
+ - `MEMANTO_AGENT_ID`: Set a custom agent ID namespace.
58
+ - `MEMANTO_RECALL_LIMIT`: Max memories to inject (default: 15).
@@ -0,0 +1,28 @@
1
+ """Cross-session engineering memory for Claude Code + mattpocock/skills.
2
+
3
+ Memanto becomes a global, active memory companion across skill executions.
4
+ Three real Claude Code lifecycle hooks make it work without manual effort:
5
+
6
+ * ``SessionStart`` -> inject the accumulated Engineering Profile once.
7
+ * ``UserPromptExpansion`` -> recall memories relevant to the skill being invoked
8
+ and inject them before Claude reads the prompt.
9
+ * ``Stop`` -> distill the just-finished session into typed memories
10
+ using Memanto's backend LLM, then persist them.
11
+
12
+ The public surface is intentionally tiny:
13
+
14
+ from claudecode_memanto import SkillMemory
15
+
16
+ mem = SkillMemory() # reads MOORCHEH_API_KEY + MEMANTO_AGENT_ID
17
+ block = mem.recall_for_skill("tdd", task_hint="auth module")
18
+ mem.distill_and_store("tdd", transcript)
19
+ """
20
+
21
+ from __future__ import annotations
22
+
23
+ from .client import SkillMemory
24
+ from .config import SkillsConfig
25
+ from .profile import MemoryProfile
26
+
27
+ __all__ = ["SkillMemory", "SkillsConfig", "MemoryProfile"]
28
+ __version__ = "0.1.0"
@@ -0,0 +1,156 @@
1
+ """``claudecode-memanto`` CLI — manual control over the skill memory layer.
2
+
3
+ The lifecycle hooks make memory automatic; this CLI is the manual escape hatch
4
+ (and what the /memanto-companion skill shells out to):
5
+
6
+ claudecode-memanto recall <skill> [--hint TEXT] # print injectable context
7
+ claudecode-memanto store <skill> "summary..." # distill + persist
8
+ claudecode-memanto profile # show accumulated profile
9
+ claudecode-memanto install [--global] # register lifecycle hooks
10
+ claudecode-memanto doctor # check config + connectivity
11
+
12
+ Uses only the standard library (argparse) to stay dependency-light.
13
+ """
14
+
15
+ from __future__ import annotations
16
+
17
+ import argparse
18
+ import sys
19
+
20
+ from .client import SkillMemory
21
+ from .config import ConfigError, SkillsConfig
22
+ from .skill_map import known_skills
23
+
24
+
25
+ def main(argv: list[str] | None = None) -> int:
26
+ """Dispatch the ``claudecode-memanto`` CLI.
27
+
28
+ Parses ``argv`` (defaulting to ``sys.argv``), runs the matching subcommand,
29
+ and returns its exit code. Network/API failures are surfaced as a single
30
+ clean error line, not a traceback.
31
+ """
32
+ parser = argparse.ArgumentParser(
33
+ prog="claudecode-memanto",
34
+ description="Cross-session engineering memory for Claude Code skills.",
35
+ )
36
+ sub = parser.add_subparsers(dest="command", required=True)
37
+
38
+ p_recall = sub.add_parser("recall", help="Print injectable context for a skill.")
39
+ p_recall.add_argument("skill", help="Skill name, e.g. tdd, grill-with-docs.")
40
+ p_recall.add_argument("--hint", default=None, help="Current task hint.")
41
+
42
+ p_store = sub.add_parser("store", help="Distill a session summary into memory.")
43
+ p_store.add_argument("skill", help="Skill name the summary came from.")
44
+ p_store.add_argument("summary", help="Free-text session summary.")
45
+
46
+ sub.add_parser("profile", help="Show the accumulated engineering profile.")
47
+ sub.add_parser("doctor", help="Check configuration and connectivity.")
48
+
49
+ p_install = sub.add_parser(
50
+ "install", help="Install the Memanto integration (hooks or prompt)."
51
+ )
52
+ p_install.add_argument(
53
+ "--method",
54
+ choices=["hooks", "prompt"],
55
+ default="hooks",
56
+ help="Installation method to use.",
57
+ )
58
+ p_install.add_argument(
59
+ "--global",
60
+ dest="global_scope",
61
+ action="store_true",
62
+ help="Install into ~/.claude/settings.json instead of ./.claude/settings.json.",
63
+ )
64
+
65
+ p_uninstall = sub.add_parser("uninstall", help="Remove the lifecycle hooks.")
66
+ p_uninstall.add_argument(
67
+ "--global",
68
+ dest="global_scope",
69
+ action="store_true",
70
+ help="Uninstall from ~/.claude/settings.json instead of ./.claude/settings.json.",
71
+ )
72
+
73
+ args = parser.parse_args(argv)
74
+
75
+ if args.command == "install":
76
+ if args.method == "prompt":
77
+ from .installer import install_prompt
78
+
79
+ return install_prompt(global_scope=args.global_scope)
80
+
81
+ from .installer import install_hooks
82
+
83
+ return install_hooks(global_scope=args.global_scope)
84
+
85
+ if args.command == "uninstall":
86
+ from .installer import uninstall_hooks
87
+
88
+ return uninstall_hooks(global_scope=args.global_scope)
89
+
90
+ if args.command == "doctor":
91
+ return _doctor()
92
+
93
+ try:
94
+ mem = SkillMemory()
95
+ except ConfigError as exc:
96
+ print(f"error: {exc}", file=sys.stderr)
97
+ return 2
98
+
99
+ try:
100
+ return _run_memory_command(mem, args)
101
+ except Exception as exc: # network/API failures — show cleanly, not as a traceback
102
+ print(f"error: {exc}", file=sys.stderr)
103
+ return 1
104
+
105
+
106
+ def _run_memory_command(mem: SkillMemory, args: argparse.Namespace) -> int:
107
+ if args.command == "recall":
108
+ profile = mem.recall_for_skill(args.skill, task_hint=args.hint)
109
+ block = profile.format_context_block(skill_name=args.skill)
110
+ if block:
111
+ print(block)
112
+ else:
113
+ print("(no relevant memories yet)", file=sys.stderr)
114
+ return 0
115
+
116
+ if args.command == "store":
117
+ stored = mem.distill_and_store(args.skill, args.summary)
118
+ print(f"stored {len(stored)} memory(ies) from /{args.skill}")
119
+ for m in stored:
120
+ mtype = m.get("type") or "memory"
121
+ title = m.get("title") or (m.get("content") or "")[:80] or "(no title)"
122
+ print(f" - [{mtype}] {title}")
123
+ return 0
124
+
125
+ if args.command == "profile":
126
+ block = mem.profile_block()
127
+ print(block or "(profile is empty)")
128
+ return 0
129
+
130
+ return 1
131
+
132
+
133
+ def _doctor() -> int:
134
+ try:
135
+ cfg = SkillsConfig.from_env()
136
+ except ConfigError as exc:
137
+ print(f"✗ config: {exc}", file=sys.stderr)
138
+ return 2
139
+ print(f"✓ MOORCHEH_API_KEY set (…{cfg.api_key[-4:]})")
140
+ print(f"✓ agent_id: {cfg.agent_id}")
141
+ print(f"✓ recall_limit: {cfg.recall_limit}, min_similarity: {cfg.min_similarity}")
142
+ print(
143
+ f"✓ curated skill routes: {', '.join(known_skills())} (others use a generic route)"
144
+ )
145
+ try:
146
+ mem = SkillMemory(cfg)
147
+ mem.setup()
148
+ print("✓ connected to Memanto and session active")
149
+ except Exception as exc:
150
+ print(f"✗ connectivity: {exc}", file=sys.stderr)
151
+ return 1
152
+ return 0
153
+
154
+
155
+ if __name__ == "__main__":
156
+ raise SystemExit(main())