ai-memory-bridge 0.1.0__py3-none-any.whl

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,4 @@
1
+ """ai-memory-bridge: Portable AI memory & custom instructions across ChatGPT, Claude, and Gemini."""
2
+
3
+ __version__ = "0.1.0"
4
+ __all__ = ["__version__"]
@@ -0,0 +1,6 @@
1
+ import sys
2
+
3
+ from .cli import main
4
+
5
+ if __name__ == "__main__":
6
+ sys.exit(main())
@@ -0,0 +1,76 @@
1
+ """CLI for ai-memory-bridge: add | import | list | export."""
2
+ from __future__ import annotations
3
+
4
+ import argparse
5
+ import sys
6
+ from pathlib import Path
7
+
8
+ from .core import export_for_provider, load_store, merge_memories, parse_plain_memories, save_store
9
+
10
+
11
+ def main(argv: list[str] | None = None) -> int:
12
+ parser = argparse.ArgumentParser(
13
+ prog="ai-memory-bridge",
14
+ description="Portable personal AI memory & custom instructions vault across ChatGPT, Claude, and Gemini.",
15
+ )
16
+ parser.add_argument("--store", default="memories.json", help="Path to local JSON memory store.")
17
+ sub = parser.add_subparsers(dest="command", required=True)
18
+
19
+ p_add = sub.add_parser("add", help="Add one memory item.")
20
+ p_add.add_argument("text", help="Memory or preference statement.")
21
+ p_add.add_argument("--category", choices=["profile", "style", "workflow", "constraints", "context"], default="context")
22
+
23
+ p_imp = sub.add_parser("import", help="Import bulleted/line-separated memories from a .txt or .md file.")
24
+ p_imp.add_argument("file", help="Path to text/markdown file.")
25
+ p_imp.add_argument("--source", default="import", help="Origin label (e.g. chatgpt, claude, gemini).")
26
+
27
+ sub.add_parser("list", help="List all stored memories grouped by category.")
28
+
29
+ p_exp = sub.add_parser("export", help="Export formatted memories for ChatGPT, Claude, or Gemini.")
30
+ p_exp.add_argument("--target", choices=["chatgpt", "claude", "gemini"], required=True)
31
+ p_exp.add_argument("--out", help="Optional output file path (prints to stdout if omitted).")
32
+
33
+ args = parser.parse_args(argv)
34
+ store_path = Path(args.store)
35
+
36
+ if args.command == "add":
37
+ existing = load_store(store_path)
38
+ incoming = parse_plain_memories(args.text, source="manual", category=args.category)
39
+ merged, added = merge_memories(existing, incoming)
40
+ save_store(store_path, merged)
41
+ print(f"Added {added} item(s). Total: {len(merged)}.")
42
+ return 0
43
+
44
+ if args.command == "import":
45
+ raw = Path(args.file).read_text(encoding="utf-8")
46
+ existing = load_store(store_path)
47
+ incoming = parse_plain_memories(raw, source=args.source)
48
+ merged, added = merge_memories(existing, incoming)
49
+ save_store(store_path, merged)
50
+ print(f"Imported {added} new item(s) ({len(incoming) - added} duplicates skipped). Total: {len(merged)}.")
51
+ return 0
52
+
53
+ if args.command == "list":
54
+ items = load_store(store_path)
55
+ if not items:
56
+ print("No memories stored yet.")
57
+ return 0
58
+ for m in items:
59
+ print(f"[{m.category}] ({m.id}) {m.text}")
60
+ return 0
61
+
62
+ if args.command == "export":
63
+ items = load_store(store_path)
64
+ output = export_for_provider(items, args.target)
65
+ if args.out:
66
+ Path(args.out).write_text(output, encoding="utf-8")
67
+ print(f"Exported {len(items)} item(s) for {args.target} -> {args.out}")
68
+ else:
69
+ print(output, end="")
70
+ return 0
71
+
72
+ return 2
73
+
74
+
75
+ if __name__ == "__main__":
76
+ sys.exit(main())
@@ -0,0 +1,131 @@
1
+ """Core memory normalization, deduplication, and provider-tailored export."""
2
+ from __future__ import annotations
3
+
4
+ import hashlib
5
+ import json
6
+ import re
7
+ from dataclasses import asdict, dataclass, field
8
+ from datetime import datetime, timezone
9
+ from pathlib import Path
10
+
11
+
12
+ @dataclass
13
+ class MemoryItem:
14
+ id: str
15
+ category: str # profile | style | workflow | constraints | context
16
+ text: str
17
+ tags: list[str] = field(default_factory=list)
18
+ source: str = "manual"
19
+ updated_at: str = ""
20
+
21
+
22
+ def _norm_key(text: str) -> str:
23
+ return re.sub(r"\s+", " ", text.strip().lower())
24
+
25
+
26
+ def _make_id(text: str) -> str:
27
+ return hashlib.sha1(_norm_key(text).encode("utf-8")).hexdigest()[:10]
28
+
29
+
30
+ def _now_iso() -> str:
31
+ return datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
32
+
33
+
34
+ def load_store(path: Path) -> list[MemoryItem]:
35
+ if not path.exists():
36
+ return []
37
+ raw = json.loads(path.read_text(encoding="utf-8"))
38
+ return [MemoryItem(**item) for item in raw.get("memories", [])]
39
+
40
+
41
+ def save_store(path: Path, items: list[MemoryItem]) -> None:
42
+ path.parent.mkdir(parents=True, exist_ok=True)
43
+ payload = {
44
+ "schema_version": 1,
45
+ "updated_at": _now_iso(),
46
+ "memories": [asdict(i) for i in items],
47
+ }
48
+ path.write_text(json.dumps(payload, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
49
+
50
+
51
+ def parse_plain_memories(raw_text: str, source: str = "import", category: str = "context") -> list[MemoryItem]:
52
+ """Parse bullet points, numbered lists, or line-separated ChatGPT/Claude/Gemini memories."""
53
+ items: list[MemoryItem] = []
54
+ seen: set[str] = set()
55
+ ts = _now_iso()
56
+ for line in raw_text.splitlines():
57
+ cleaned = re.sub(r"^\s*(?:[-*•]|\d+[.)])\s*", "", line).strip()
58
+ if not cleaned or cleaned.startswith("#"):
59
+ continue
60
+ key = _norm_key(cleaned)
61
+ if key in seen:
62
+ continue
63
+ seen.add(key)
64
+ inferred = category
65
+ low = cleaned.lower()
66
+ if any(k in low for k in ("never ", "do not ", "don't ", "avoid ", "严禁", "不要")):
67
+ inferred = "constraints"
68
+ elif any(k in low for k in ("concise", "tone", "bullet", "markdown", "style", "简洁", "中文")):
69
+ inferred = "style"
70
+ elif any(k in low for k in ("i am ", "my name", "developer", "engineer", "student", "我是")):
71
+ inferred = "profile"
72
+ items.append(MemoryItem(id=_make_id(cleaned), category=inferred, text=cleaned, source=source, updated_at=ts))
73
+ return items
74
+
75
+
76
+ def merge_memories(existing: list[MemoryItem], incoming: list[MemoryItem]) -> tuple[list[MemoryItem], int]:
77
+ by_key = {_norm_key(i.text): i for i in existing}
78
+ added = 0
79
+ for item in incoming:
80
+ k = _norm_key(item.text)
81
+ if k not in by_key:
82
+ by_key[k] = item
83
+ added += 1
84
+ return list(by_key.values()), added
85
+
86
+
87
+ def export_for_provider(items: list[MemoryItem], target: str) -> str:
88
+ grouped: dict[str, list[MemoryItem]] = {}
89
+ for item in items:
90
+ grouped.setdefault(item.category, []).append(item)
91
+
92
+ order = ["profile", "style", "workflow", "constraints", "context"]
93
+ labels = {
94
+ "profile": "About Me",
95
+ "style": "Response Style",
96
+ "workflow": "Workflow & Tools",
97
+ "constraints": "Hard Constraints",
98
+ "context": "Additional Context",
99
+ }
100
+
101
+ if target == "chatgpt":
102
+ # Respect ChatGPT Custom Instructions (~1500 char per box guidance) with compact bullets
103
+ lines = ["[Custom Instructions — Imported via ai-memory-bridge]", ""]
104
+ for cat in order:
105
+ if cat in grouped:
106
+ lines.append(f"{labels[cat]}:")
107
+ for m in grouped[cat]:
108
+ lines.append(f"- {m.text}")
109
+ lines.append("")
110
+ return "\n".join(lines).rstrip() + "\n"
111
+
112
+ if target == "claude":
113
+ lines = ["<user_preferences>"]
114
+ for cat in order:
115
+ if cat in grouped:
116
+ lines.append(f" <{cat}>")
117
+ for m in grouped[cat]:
118
+ lines.append(f" - {m.text}")
119
+ lines.append(f" </{cat}>")
120
+ lines.append("</user_preferences>")
121
+ return "\n".join(lines) + "\n"
122
+
123
+ if target == "gemini":
124
+ lines = ["# Saved Info for Gemini", ""]
125
+ for cat in order:
126
+ if cat in grouped:
127
+ for m in grouped[cat]:
128
+ lines.append(f"- [{labels[cat]}] {m.text}")
129
+ return "\n".join(lines) + "\n"
130
+
131
+ raise ValueError(f"Unsupported target: {target}")
@@ -0,0 +1,55 @@
1
+ Metadata-Version: 2.4
2
+ Name: ai-memory-bridge
3
+ Version: 0.1.0
4
+ Summary: Portable personal AI memory & custom instructions vault across ChatGPT, Claude, and Gemini.
5
+ Author: HbuAsherLucas
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/HbuAsherLucas/ai-memory-bridge
8
+ Project-URL: Repository, https://github.com/HbuAsherLucas/ai-memory-bridge
9
+ Project-URL: Issues, https://github.com/HbuAsherLucas/ai-memory-bridge/issues
10
+ Keywords: chatgpt,claude,gemini,memory,custom-instructions,prompts,cli
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: Intended Audience :: End Users/Desktop
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Requires-Python: >=3.11
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Provides-Extra: dev
21
+ Requires-Dist: pytest>=8.0; extra == "dev"
22
+ Dynamic: license-file
23
+
24
+ # ai-memory-bridge
25
+
26
+ [![CI](https://github.com/HbuAsherLucas/ai-memory-bridge/actions/workflows/ci.yml/badge.svg)](https://github.com/HbuAsherLucas/ai-memory-bridge/actions/workflows/ci.yml)
27
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
28
+ [![Zero Dependencies](https://img.shields.io/badge/dependencies-0%20(stdlib%20only)-brightgreen.svg)](pyproject.toml)
29
+
30
+ **Your AI memory should belong to you, not one vendor.**
31
+
32
+ `ai-memory-bridge` is a zero-dependency local CLI that imports, deduplicates, categorizes, and version-controls your personal AI memories and preferences, then exports clean, tailored blocks ready for **ChatGPT Custom Instructions**, **Claude Profile / XML Preferences**, and **Gemini Saved Info**.
33
+
34
+ ## Quickstart
35
+
36
+ ```bash
37
+ git clone https://github.com/HbuAsherLucas/ai-memory-bridge.git
38
+ cd ai-memory-bridge
39
+ pip install -e .
40
+
41
+ # Import your exported ChatGPT / Claude / Gemini memory list:
42
+ ai-memory-bridge import my_memories.txt --source chatgpt
43
+
44
+ # Add a preference manually:
45
+ ai-memory-bridge add "Prefer concise answers with runnable code examples." --category style
46
+
47
+ # Export formatted preferences for each provider:
48
+ ai-memory-bridge export --target chatgpt
49
+ ai-memory-bridge export --target claude
50
+ ai-memory-bridge export --target gemini
51
+ ```
52
+
53
+ ## License
54
+
55
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,10 @@
1
+ ai_memory_bridge/__init__.py,sha256=NtsqmiDgUNe3Zsl03nF1Cv5eawgrN97PHPgj_OZ_8xw,150
2
+ ai_memory_bridge/__main__.py,sha256=4JMK66Wj4uLZTKbF-sT3LAxOsr6buig77PmOkJCRRxw,83
3
+ ai_memory_bridge/cli.py,sha256=T0HC88Qvy0NIbe5K9T9TnwFpTepzumtrGPdNZtqA1IQ,3099
4
+ ai_memory_bridge/core.py,sha256=3WRQxbgozRuPL1gCZlj1MoF_BBcTmd40DcxkN7PjT_U,4559
5
+ ai_memory_bridge-0.1.0.dist-info/licenses/LICENSE,sha256=_YeeoBww4CjnaX9jdBPaSnTkaLsVNFcM0zo-HFljDBM,1070
6
+ ai_memory_bridge-0.1.0.dist-info/METADATA,sha256=IRDwF_lxWyehyj8Cu9EzKseMRXL91KfrO_AgBX5ZxCA,2296
7
+ ai_memory_bridge-0.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
8
+ ai_memory_bridge-0.1.0.dist-info/entry_points.txt,sha256=nVGCyBUY3RE7rXs7O2hotLw3r4HworZV5ol7xmrrOk8,63
9
+ ai_memory_bridge-0.1.0.dist-info/top_level.txt,sha256=5DFgCyAuHCRs2tuyNUPu0xQc3Gb0sh8FujJ5KS2gNrs,17
10
+ ai_memory_bridge-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (84.2.1)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ ai-memory-bridge = ai_memory_bridge.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 HbuAsherLucas
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.
@@ -0,0 +1 @@
1
+ ai_memory_bridge