n3memorycore-free-codex 1.9.2__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,30 @@
1
+ """Resolve N3MemoryCore's data and child-process paths."""
2
+ import os
3
+ import sys
4
+ from pathlib import Path
5
+
6
+ _root = os.environ.get("N3MC_FREE_CODEX_HOME") or "~/.n3mc-free-codex"
7
+ HOME_DIR = os.path.abspath(os.path.expanduser(_root))
8
+ MEMORY_DIR = os.path.join(HOME_DIR, ".memory")
9
+ CONFIG_FILE = os.path.join(HOME_DIR, "config.json")
10
+ DB_PATH = os.path.join(MEMORY_DIR, "n3memory.db")
11
+ PID_FILE = os.path.join(MEMORY_DIR, "n3mc.pid")
12
+ AUDIT_LOG = os.path.join(MEMORY_DIR, "audit.log")
13
+ NOTICES_FILE = os.path.join(MEMORY_DIR, "notices.json")
14
+ SERVER_LOG = os.path.join(MEMORY_DIR, "server.log")
15
+ SERVER_START_FAILED_FILE = os.path.join(MEMORY_DIR, "server_start_failed")
16
+
17
+
18
+ def python_cmd():
19
+ """Keep child processes isolated unless they need the source checkout to import."""
20
+ command = [sys.executable]
21
+ if sys.flags.isolated:
22
+ return command + ["-I"]
23
+ if sys.version_info >= (3, 11):
24
+ try:
25
+ in_checkout = Path.cwd() == Path(__file__).absolute().parents[1]
26
+ except OSError:
27
+ in_checkout = True
28
+ if not in_checkout:
29
+ command.append("-P")
30
+ return command
@@ -0,0 +1,24 @@
1
+ """Choose the project label forwarded to the connected memory server."""
2
+ import os
3
+ import subprocess
4
+ from pathlib import Path
5
+
6
+
7
+ def detect_project(cwd=None):
8
+ directory = cwd or os.getcwd()
9
+ try:
10
+ result = subprocess.run(
11
+ ["git", "rev-parse", "--show-toplevel"],
12
+ cwd=directory,
13
+ stdout=subprocess.PIPE,
14
+ stderr=subprocess.DEVNULL,
15
+ encoding="utf-8",
16
+ check=True,
17
+ timeout=2,
18
+ )
19
+ root = Path(result.stdout.rstrip("\r\n")).name
20
+ if root:
21
+ return root
22
+ except (OSError, subprocess.SubprocessError, ValueError):
23
+ pass
24
+ return Path(os.path.abspath(directory)).name or None
@@ -0,0 +1,424 @@
1
+ Metadata-Version: 2.4
2
+ Name: n3memorycore-free-codex
3
+ Version: 1.9.2
4
+ Summary: Persistent hybrid-search memory store for Codex (Free Edition)
5
+ Author: N3MemoryCore contributors
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/NeuralNexusNote/n3mc-free-codex
8
+ Project-URL: Issues, https://github.com/NeuralNexusNote/n3mc-free-codex/issues
9
+ Keywords: codex,memory,rag,embedding,sqlite-vec
10
+ Classifier: Development Status :: 4 - Beta
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: Microsoft :: Windows
13
+ Classifier: Operating System :: POSIX :: Linux
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Classifier: Programming Language :: Python :: 3.11
17
+ Classifier: Programming Language :: Python :: 3.12
18
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
19
+ Requires-Python: >=3.10
20
+ Description-Content-Type: text/markdown
21
+ License-File: LICENSE
22
+ License-File: NOTICE
23
+ Requires-Dist: fastapi>=0.110
24
+ Requires-Dist: uvicorn>=0.27
25
+ Requires-Dist: pydantic>=2.0
26
+ Requires-Dist: sentence-transformers>=2.5
27
+ Requires-Dist: sqlite-vec>=0.1.6
28
+ Requires-Dist: uuid7>=0.1.0
29
+ Requires-Dist: psutil>=5.9
30
+ Provides-Extra: test
31
+ Requires-Dist: pytest>=7.0; extra == "test"
32
+ Requires-Dist: httpx>=0.27; extra == "test"
33
+ Dynamic: license-file
34
+
35
+ # N3MemoryCore Free for Codex (n3mc-free-codex) v1.9.2
36
+
37
+ **Give Codex a memory across conversations. Free, on your own PC.**
38
+
39
+ Do you find yourself explaining an earlier decision and its reasons again in a new chat or another project?
40
+ N3MemoryCore saves your messages and Codex's replies on your PC and recalls them when related topics arise.
41
+ You do not need to say “remember this” each time. Two trusted hooks handle saving and retrieval.
42
+ N3MC supplies the **conversation-history layer**. Use it alongside standing instructions such as `AGENTS.md`.
43
+
44
+ The primary deliverable is the **implementation specification**. Your own Codex generates the code, sets it up and verifies it.
45
+
46
+ **For first-time users.** After building Free with the steps below, start a new chat in the same project and say “We chose blue for the prototype cover.” In another new chat, ask “Which color did we choose for the prototype cover?” Check the answer and the retrieved record. Keep the generated source and `tests/` for a later upgrade to Pro.
47
+
48
+ 1. Create a dedicated empty folder in File Explorer.
49
+ 2. Put `N3MemoryCore_v1.9.2_Free_EN.md` in that folder.
50
+ 3. Open the folder as a local workspace in Codex.
51
+ 4. Ask: “Implement this specification, complete setup, and run the verification tests.”
52
+ 5. Review and trust both registered hooks in **Settings → Hooks** (CLI: `/hooks`). Codex performs the tests that follow.
53
+
54
+ Check Codex's **Evidence Report** for passing tests, including saving in a new chat and retrieval from another chat. See [Setup](#setup) for details.
55
+
56
+ > **⚠️ Disclaimer**
57
+ >
58
+ > - **No support, no claims**: This project is provided as-is with no support. Questions, bug reports, and feature requests are not guaranteed a response. Use entirely at your own discretion.
59
+ > - **Use at your own risk**: This system runs on AI-generated code. The author is not responsible for any data changes or issues caused by its use.
60
+ > - **Backup first**: Always back up your current environment before running this on important projects.
61
+
62
+ > **⚠️ How long memories are kept, and data size**
63
+ >
64
+ > - **Memories are not deleted.** Free has no feature that deletes old records.
65
+ > - **More data makes it slower.** The more records there are, the longer a search takes.
66
+
67
+ > A NeuralNexusNote™ product
68
+ >
69
+ > 🇯🇵 **[Click here for the Japanese Documentation (日本語版)](./README_JP.md)**
70
+ > 🛡️ **[Development Philosophy & AI-Native Policy](./PHILOSOPHY.md)**
71
+
72
+ ## How It Works
73
+
74
+ ```text
75
+ Your message → Search earlier memories → Save the current message
76
+ ↓
77
+ Pass the results to Codex
78
+ ↓
79
+ Codex replies
80
+ ↓
81
+ Stop hook saves the reply
82
+ ```
83
+
84
+ Powered by Codex's hook system. Everything happens automatically — no user action required.
85
+
86
+ - **What is saved** — eligible messages and replies received by the hooks. Long messages are split into chunks; explicit opt-outs and inputs detected as containing secrets are excluded. A fenced code block is saved as `[code omitted]`: N3MC remembers what was said and decided, and the code is in your project's files.
87
+ - **What is recalled** — with every message, the hook searches the memory and adds the related records to Codex's context, before Codex reads your message.
88
+
89
+ ### Three scenes
90
+
91
+ > **Monday** — You and Codex decide to use PostgreSQL for the website, and say why.
92
+ >
93
+ > **Wednesday** — In a new session you ask which database you chose. Monday's decision and its reason arrive in Codex's context together with your question. You do not explain it again.
94
+ >
95
+ > **Friday** — You are working in another folder. When the subject comes up, Monday's decision is recalled there too: Free keeps one memory for all your project folders.
96
+
97
+ ### An example of what Codex receives
98
+
99
+ This illustrates the search-output format. Records saved by Claude Code on a connected server can also be retrieved; their agent labels and the stored reply label `[claude]` are retained.
100
+
101
+ ```text
102
+ # Recalled Memory Context
103
+ Search query: Which database did we decide to use for the website, and why?
104
+
105
+ ## Top matches (use these to answer the question)
106
+
107
+ _If several versions of the same content appear, the one with the newest `saved` time is the current one._
108
+
109
+ ## [1] score=0.5283 saved=2026-11-22 15:58 (UTC+0900) claude-code
110
+ [user] Let's use PostgreSQL for the website's database. Several people will edit at the same time, and SQLite locks the whole file on every write.
111
+
112
+ ## Possibly related (weak matches — may be unrelated)
113
+
114
+ ## [2] score=0.3339 saved=2026-11-22 15:58 (UTC+0900) claude-code
115
+ [claude] Agreed, PostgreSQL it is. The reason, for the record: several editors at the same time, and SQLite allows one writer at a time. Next step: write the schema for the articles table.
116
+
117
+ ## Previous matching Q-A exchanges (supplementary context)
118
+
119
+ ### turn_id: 9df50a6f-8a92-4401-b096-9e3daec22566 saved=2026-11-22 15:58 (UTC+0900)
120
+ [user] Let's use PostgreSQL for the website's database. Several people will edit at the same time, and SQLite locks the whole file on every write.
121
+ [claude] Agreed, PostgreSQL it is. The reason, for the record: several editors at the same time, and SQLite allows one writer at a time. Next step: write the schema for the articles table.
122
+ ```
123
+
124
+ `Top matches` are the records that passed the relevance floors. `Possibly related` are the closest of the records that did not. The last part shows the whole exchange a top match belongs to.
125
+
126
+ ### Standing instructions and conversation memory
127
+
128
+ | | Instructions such as `AGENTS.md` | N3MemoryCore |
129
+ |---|---|---|
130
+ | Main role | State working rules and recurring information | Retain earlier messages, replies and their reasons |
131
+ | Use | The user maintains the required instructions | Hooks save conversations and search them when related topics arise |
132
+ | Consideration | Make standing instructions explicit | Retrieval depends on search; recall is not guaranteed |
133
+
134
+ Keep recurring rules in instruction files and use N3MC for conversation history and the reasons behind decisions.
135
+
136
+ ## About this project
137
+
138
+ 🛡️ AI-Native Development Policy
139
+ This project prioritizes Instructions over Static Code. Please read our [Development Philosophy](./PHILOSOPHY.md) to understand why you should let AI generate your execution environment.
140
+
141
+ > I know Java and C#, but Python is completely new to me.
142
+ > The code Claude Code generated — I built it without fully understanding it.
143
+ >
144
+ > But I tested it, refined the specification, rebuilt it,
145
+ > and shipped both Japanese and English versions — Free and Pro.
146
+ >
147
+ > Because if I could do it, so can you.
148
+ >
149
+ > The first draft of the specification was written by Copilot.
150
+ > Claude Code turned it into working code. Gemini reviewed it.
151
+ > Iterated across three AIs — that process is N3MemoryCore.
152
+
153
+ **Two ways to install**: The primary route is to have Codex implement the specification, configure it and verify it. The reference code is an alternative. In either case, the user reviews and trusts the registered hooks.
154
+
155
+ ## Free or Lite? Which one to use
156
+
157
+ Free and MCP Lite are the two free N3MemoryCore products. This README describes **Free for Codex**.
158
+
159
+ | | Free for Codex | [N3MC MCP Lite](https://github.com/NeuralNexusNote/n3mcmcp-lite) |
160
+ |---|---|---|
161
+ | Use | Save and search through Codex hooks | Call memory tools from MCP clients; supported editions also have Claude Code hooks |
162
+ | Saving | Automatically saves eligible messages and replies | The AI decides what to save over MCP; hook-enabled editions save conversations automatically |
163
+ | Retention | No expiry | Automatically deleted after 7 days |
164
+ | Requirements | Python 3.10+ | Python 3.10+ and Docker (Redis Stack) |
165
+ | Setup | Generate and configure from the Codex specification | Use the Lite specification and configuration for your application |
166
+
167
+ - **Free for Codex** — For long-term Codex conversation memory. Normal saving and search require neither an MCP connection nor Docker.
168
+ - **MCP Lite** — For MCP clients or short-lived working memory. Check the supported client and required software for that edition.
169
+
170
+ **Free for Codex is not intended for:**
171
+
172
+ - Use as an MCP tool from other applications.
173
+ - Automatic removal of old records or deletion of individual records; Free has no such commands.
174
+ - Automatic synchronization between PCs; Free for Codex has no synchronization feature.
175
+
176
+ ## Features
177
+
178
+ | You want to… | N3MemoryCore… | How |
179
+ |---|---|---|
180
+ | Stop explaining the same thing again | saves every message and reply, and recalls the related ones on every turn | Codex hooks (`UserPromptSubmit`, `Stop`). No tool call, no manual step |
181
+ | Find things in your own words | finds a past conversation even when the exact words differ | Vector search with `intfloat/multilingual-e5-base` (Japanese, English, Chinese, Korean and ~100 other languages) plus keyword search |
182
+ | Pick up tomorrow where you left off | keeps the memory across sessions and across project folders | One database for every folder; the conversation you are in is ranked first |
183
+ | Keep your data at home | stores the memory in a file on your own PC, not in any cloud service | SQLite. Only the memories recalled for a turn are sent to Codex, together with your message ([details](#your-memory-stays-on-your-pc)) |
184
+ | Spend fewer tokens | does the search with local embeddings (zero Codex tokens) and injects only the related records | The recalled block is capped (`top_matches_max`, `min_results`) |
185
+ | Let several agents share one memory | keeps who wrote each record | `agent_name`, `local_id`. Ranking each agent's own memories first is a Pro feature |
186
+ | Share memory with an existing Free/Pro server | saves and searches through a verified server on the same PC | Configure its data root and port (see connection settings below) |
187
+
188
+ To use another embedding model, set it in `config.json` and run `n3mc-free-codex --reembed`; the model must produce 768-dimension vectors.
189
+
190
+ ## Your Memory Stays on Your PC
191
+
192
+ An AI that remembers you is convenient, but it is natural to ask where those memories are kept. N3MemoryCore keeps them in one place you control: a folder on your own PC.
193
+
194
+ - **One local file** — Standalone memory is stored in a single SQLite file, `~/.n3mc-free-codex/.memory/n3memory.db`. There is no N3MC account and no N3MC cloud service. To move it, set `N3MC_FREE_CODEX_HOME` (see [Optional: change where data lives](#optional-change-where-data-lives)).
195
+ - **The raw input is kept next to it** — `~/.n3mc-free-codex/.memory/audit.log` holds the raw text of nonexcluded hook calls (your messages and Codex's replies, code blocks included). It is rotated at 50 MB, and `n3mc-free-codex --list` does not show it. Treat it as private data, like the database.
196
+ - **Search runs on your PC** — The embedding model and the search run locally. N3MC's server listens only on `127.0.0.1` and rejects requests for any other host name, so other machines on your network cannot reach it.
197
+ - **No telemetry** — N3MC sends no usage data anywhere. The code is open, so you can check this yourself.
198
+ - **You can see and remove everything** — `n3mc-free-codex --list` shows what is stored. Deleting `~/.n3mc-free-codex/` removes all of it (see [Uninstall](#uninstall)). Backing up is copying two files (see [Backup and restore](#backup-and-restore)).
199
+
200
+ What does go over the network:
201
+
202
+ - **The embedding model download** — On the first search, `intfloat/multilingual-e5-base` (about 1.1 GB) is downloaded from Hugging Face. After that, the Hugging Face library may still check for model updates when the model loads; set `HF_HUB_OFFLINE=1` to stop this once the model is downloaded.
203
+ - **What Codex reads** — The memories recalled for a turn are added to that turn's prompt, so they are sent to OpenAI together with your message, as everything you type into Codex is. N3MC does not upload your memory database anywhere, but the parts Codex uses in a turn are part of that conversation.
204
+
205
+ In connected mode, memories are stored on the target server. The Codex-side audit remains local.
206
+
207
+ ## Free vs Pro
208
+
209
+ | | Free | Pro |
210
+ |---|---|---|
211
+ | Core features (save, search, automatic recall) | ✅ | ✅ |
212
+ | Exact duplicates within the same turn skipped; the newest version of the same content listed first | ✅ | ✅ |
213
+ | The conversation you are in ranked first (`b_session`) | ✅ | ✅ |
214
+ | The current project's memories recalled first | - | ✅ |
215
+ | Search that stays fast as the memory grows | - | ✅ Above 20,000 records an in-memory index narrows the candidates |
216
+ | The previous session's thread at session start | - | ✅ |
217
+ | Your own agent's / install's memories ranked first (`b_local`) | - | ✅ |
218
+ | Delete individual records | - | ✅ |
219
+ | Retention period (`--gc`) | - | ✅ Off by default; you run it yourself |
220
+ | Export / import | - | ✅ Data migration & sharing |
221
+ | Entity index | - | ✅ |
222
+
223
+ Nothing is deleted or replaced automatically in either edition.
224
+
225
+ For Pro, choose the specification for your host. Check the destination and import-ID behavior when moving records. Connecting to an existing Free/Pro server is another option.
226
+
227
+ ## Specification Files
228
+
229
+ | File | Description |
230
+ |---|---|
231
+ | `N3MemoryCore_v1.9.2_Free_JP.md` | Free edition (Japanese) |
232
+ | `N3MemoryCore_v1.9.2_Free_EN.md` | Free edition (English) |
233
+
234
+ > 💡 **A note on annotations in the specification**
235
+ > Throughout the specification file (Markdown), you'll find annotations describing the design intent behind each instruction — written to give you precise control over AI behavior. Before having Codex generate the code, take a moment to read through them. They contain more than just code: the logic behind how to work with AI effectively.
236
+
237
+ ## Setup
238
+
239
+ **Method A, generating from the specification, is the primary route.** Method B is for those who want to use the reference code directly.
240
+
241
+ ### Method A: Generate from the specification (primary, recommended)
242
+
243
+ 1. **Create a dedicated folder** — Start with an empty folder, for example `C:/Users/<you>/n3mc-free-codex`. The generated code stays in use there.
244
+ 2. **Add the specification** — Put `N3MemoryCore_v1.9.2_Free_EN.md` in the folder. Do not mix it with another project.
245
+ 3. **Open it in Codex** — Use that folder as a local workspace.
246
+ 4. **Ask for implementation** — Send:
247
+
248
+ ```text
249
+ Implement N3MemoryCore Free for Codex according to N3MemoryCore_v1.9.2_Free_EN.md. Complete prerequisite checks, installation, hook registration, and the tests in sections 6 and 7. After registration, show me the two hooks to review and trust. Once trusted, perform the test inputs and verification commands yourself and report the results in the Evidence Report.
250
+ ```
251
+
252
+ Codex checks the destination, Python and dependencies, then generates the code, installs it and registers the hooks. An already authorized destination does not need another confirmation. It must not overwrite another project.
253
+
254
+ 5. **Trust both hooks** — In **Settings → Hooks** (CLI: `/hooks`), review and trust both `UserPromptSubmit` and `Stop` labeled `N3MC-Free-Codex memory`.
255
+ 6. **Read the results** — Codex runs tests in new chats. Check the three-turn capture, cross-chat retrieval and opt-out tests in §6.1–§6.2, and the §7 test results.
256
+
257
+ **Generating code or registering hooks alone does not complete setup. Check the Evidence Report for passing required tests.** Any unverified item still needs verification.
258
+
259
+ The first model download may take several minutes. Moving or deleting an editable installation's source folder later breaks its hooks.
260
+
261
+ ### Method B: Install the reference code (optional)
262
+
263
+ #### 1. Install
264
+
265
+ ```bash
266
+ git clone https://github.com/NeuralNexusNote/n3mc-free-codex.git
267
+ cd n3mc-free-codex
268
+ python -m pip install -e ".[test]"
269
+ ```
270
+
271
+ Python 3.10+ is required. The embedding model is downloaded on first use.
272
+
273
+ #### 2. Connect to Codex
274
+
275
+ ```bash
276
+ n3mc-free-codex --init
277
+ ```
278
+
279
+ - Creates `~/.n3mc-free-codex` and `config.json`, with `owner_id` and `local_id`. It initializes the DB in standalone mode.
280
+ - Registers `UserPromptSubmit` and `Stop` in the user's `~/.codex/hooks.json`; when `CODEX_HOME` is set, it uses that folder's `hooks.json`.
281
+ - Uses the installed Python's absolute path, a 120-second timeout and the `N3MC-Free-Codex memory` label.
282
+ - Preserves other handlers and backs up settings before changes. Invalid JSON is left untouched; repeated execution does not duplicate this edition's handlers.
283
+
284
+ The command does not grant hook trust. Codex uses the user's approval and sandbox settings.
285
+
286
+ #### 3. Verify hook registration
287
+
288
+ Have Codex check the configuration path, Python interpreter, one handler per event, and the 120-second timeout. For a manual Method B check, this command should print `OK`:
289
+
290
+ ```bash
291
+ python -c "import os,json,base64,re; from pathlib import Path; p=Path(os.environ.get('N3MC_CODEX_HOOKS_PATH') or str(Path(os.environ.get('CODEX_HOME') or str(Path.home()/'.codex'))/'hooks.json')).expanduser(); h=json.loads(p.read_text(encoding='utf-8-sig')).get('hooks',{}); norm=lambda c: base64.b64decode(c.rsplit(' ',1)[-1]).decode('utf-16le') if '-EncodedCommand ' in c else c; groups=[[x for g in h.get(e,[]) for x in g.get('hooks',[]) if x.get('type')=='command' and re.search(r'(?<![A-Za-z0-9_.-])n3memorycore_free_codex[.]codex_entry(?![A-Za-z0-9_.-])',norm(x.get('command',''))) and re.search(r'(?<![A-Za-z0-9_-])'+f+r'(?![A-Za-z0-9_-])',norm(x.get('command','')))] for e,f in [('UserPromptSubmit','--prompt'),('Stop','--stop')]]; assert all(len(g)==1 and g[0].get('timeout')==120 for g in groups), 'Free Codex hook registration missing, duplicated or invalid'; print('OK')"
292
+ ```
293
+
294
+ `OK` checks registration structure. It does not prove trust or that a conversation was saved. If registration is missing, rerun `n3mc-free-codex --init` with the same Python.
295
+
296
+ #### 4. Review and trust the hooks
297
+
298
+ In **Settings → Hooks** (CLI: `/hooks`), review and trust `UserPromptSubmit` and `Stop` labeled `N3MC-Free-Codex memory`. Then start a new chat in a workspace outside the installation folder.
299
+
300
+ #### 5. Confirm it works
301
+
302
+ Have Codex execute §6.1–§6.2 of the specification. All three turns must contain an input (`[user]`) and reply (`[claude]`), with matching `turn_id` values within each pair and different IDs across turns. `agent_name` is `codex`; all pairs from the same chat share one `session_id`. Do not substitute manual `--buffer` calls for automatic capture.
303
+
304
+ ```bash
305
+ n3mc-free-codex --list --format jsonl
306
+ ```
307
+
308
+ Also verify retrieval in another chat whose questions omit the answers, exclusion of both opted-out input and reply, and the §7 test results. In connected mode, inspect the target DB.
309
+
310
+ #### Optional: change where data lives
311
+
312
+ Set `N3MC_FREE_CODEX_HOME` to an absolute path before `--init`, in an environment visible to both Codex and the verification terminal. A terminal-only setting does not reach a separately launched Codex. Reopen Codex and the terminal after changing the variable so they inherit it.
313
+
314
+ ### Troubleshooting
315
+
316
+ **`n3mc-free-codex: command not found`**
317
+ The installed Python's `Scripts/` (Windows) or `bin/` (Linux) may not be on PATH. Use `python -m n3memorycore_free_codex.n3memory --init` with the same interpreter, and check that you have not switched Python environments.
318
+
319
+ **Registered hooks, but no records**
320
+ Have Codex inspect trust, execution errors, the registered interpreter and the data root. In connected mode, the Codex edition's `--list` does not read the target; inspect the target DB. Ordinary turns leave entries in `.memory/audit.log`; opt-out and secret exclusions suppress the audit too.
321
+
322
+ **The prompt is saved but the reply is missing**
323
+ Inspect `Stop`. If both are saved but another chat cannot retrieve them, inspect that chat's `UserPromptSubmit` output.
324
+
325
+ **The first search is unavailable**
326
+ Model download or loading may take time. Inspect the error and `.memory/server.log` under the data root. An unavailable search is not evidence of successful saving or completed verification.
327
+
328
+ ### What to expect after setup
329
+
330
+ - Related earlier conversations are searched and passed to Codex.
331
+ - Hooks save messages and replies; repeated manual saving is unnecessary.
332
+ - Codex briefly acknowledges recalled information when it actually uses it.
333
+ - Failed saves are reported. Successful automatic saves do not produce an acknowledgment each time.
334
+
335
+ ### Search settings
336
+
337
+ Standalone settings are in `~/.n3mc-free-codex/config.json`; see the specification for their names and meanings. Connected mode uses the target's search settings.
338
+
339
+ ### Backup and restore
340
+
341
+ Keep `.memory/n3memory.db` (memory data) and `config.json` (including `owner_id` and `local_id`) together. Use SQLite's backup facility for a running DB, or stop the relevant standalone server before making a consistent copy. Restore both files to the same data root.
342
+
343
+ Keep `audit.log` and `audit.log.1` too if you need raw text. In connected mode, back up the target DB and settings as well as the Codex-side audit.
344
+
345
+ ### Uninstall
346
+
347
+ You can ask Codex: “Remove N3MemoryCore Free for Codex, but keep my memory data.” To do it yourself:
348
+
349
+ 1. Remove only this edition's `UserPromptSubmit` and `Stop` registrations from Codex settings. Preserve other products' hooks.
350
+ 2. If this edition's standalone server is running, identify it by command and data root and stop only that server. Do not stop a connected Free/Pro target.
351
+ 3. Uninstall with the Python used for installation.
352
+
353
+ ```bash
354
+ python -m pip uninstall n3memorycore-free-codex
355
+ ```
356
+
357
+ 4. Keep the data folder for restoration. Delete it only if you also want to erase the memory and have checked your backup; deleted data cannot be recovered.
358
+
359
+ ### Connect to an original Free or Pro server
360
+
361
+ If an original Free/Pro server already runs on the same PC, Codex can save and search conversations there. Set its port and absolute data-folder path in the Codex edition's `config.json`.
362
+
363
+ ```json
364
+ {
365
+ "connect_server_port": 18521,
366
+ "connect_server_root": "C:/Users/<you>/.n3mc-pro"
367
+ }
368
+ ```
369
+
370
+ This is a Pro example. Set both values for the actual target and start it beforehand. Clear both to return to standalone mode.
371
+
372
+ - Save and search on the target only after verifying it. The client does not start, stop or repair the target.
373
+ - Codex keeps a local audit but does not duplicate connected records in a local DB. An unavailable target does not trigger a fallback to another DB.
374
+ - The Codex edition's `--list`, `--show-turn` and `--recall-thread` read local data. Read connected full text with the target product's CLI and data root (specification §3).
375
+ - `--list --format jsonl` exports all IDs from standalone records. Which IDs survive import depends on the receiver; verify this with disposable data before migration.
376
+
377
+ ## ID Hierarchy
378
+
379
+ N3MemoryCore uses 6 ID fields to identify the origin and context of each record:
380
+
381
+ | ID | Stored in | Generated | Granularity | Purpose |
382
+ |---|---|---|---|---|
383
+ | `id` (PK) | DB record | Per record (UUIDv7, time-ordered) | **One record** | Unique identifier for each memory |
384
+ | `owner_id` | `config.json` | First startup (UUIDv4) | **Owner / data folder** | Identifies whose data this is — for shared/multi-user scenarios and import provenance |
385
+ | `local_id` | `config.json` / API | First startup (UUIDv4), or per request | **Install** | One Codex install has one `local_id`; it is the same in every session. Stored on every record (in Free it is not used in ranking; `b_local` is a Pro feature) |
386
+ | `session_id` | Supplied by Codex (hook input), else made per process | Per conversation | **One conversation** | Groups the memories of one conversation. In Free, drives the `b_session` ranking bias (match=1.0, mismatch=0.6) so the ongoing exchange ranks above unrelated past sessions |
387
+ | `turn_id` | DB record | Supplied by the Codex hook event | **One exchange** | Ties one user message to the reply that answers it; `--show-turn` and `--recall-thread` take it |
388
+ | `agent_name` | DB record | Per save (free-form string) | **Display label** | Human-readable label of the writer (`"codex"` for the hooks). `--buffer --agent-id <name>` sets this field |
389
+
390
+ ```
391
+ owner_id (the data folder ~/.n3mc-free-codex and its owner)
392
+ └── local_id (the install; the same in every session)
393
+ └── session_id (one Codex conversation)
394
+ └── turn_id (one exchange: one user message and the reply to it)
395
+ └── id (one record = one chunk)
396
+
397
+ agent_name (a display label, outside the hierarchy: "codex" for the hooks)
398
+ ```
399
+
400
+ ## Requirements
401
+
402
+ - A local **Codex** client supporting command hooks.
403
+ - **Python 3.10+**. Codex follows the specification to guide you if prerequisites are missing.
404
+ - **Target OS**: Windows 11 and Ubuntu. macOS is not supported.
405
+
406
+ ## Extensibility
407
+
408
+ Discuss extensions with Codex. The following are examples of additions made by changing the specification; distinguish them from the standard Free Codex features.
409
+
410
+ - **MCP server** — Expose N3MC as an MCP server so other AI tools can access the memory
411
+ - **PostgreSQL migration** — Move from SQLite to PostgreSQL + pgvector (a ready-made edition for a team in one organization is N3MC Pro on PostgreSQL, `n3mc-pro-postgres`)
412
+ - **Custom search logic** — Tune bias coefficients and ranking formulas
413
+ - **Alternative embedding models** — Swap in a different model to suit your use case
414
+ - **Keyword-search tokenizer** — The default keyword index (FTS5 `trigram`, plus a 2-character index for Japanese, Chinese and Korean) was chosen because it works both for languages written without spaces and for languages like English . Adapt the final tokenizer to your own language and environment (e.g. `porter unicode61` to fold English word forms, or a morphological analyzer for higher Japanese precision). Codex can do it for you, including the start-up check that otherwise rebuilds the index as `trigram`, and rebuilding the existing DB's FTS index
415
+ - **Custom ID fields** — Add fields like `project_id` or `tag` to organize memories your way
416
+ - **PDF import** — Extract text from PDF files and store them as searchable memories
417
+ - **Hashtag support** — Codex auto-tags memories with `#hashtags` for filtered search (e.g. `--search "#AWS"`) — works with existing FTS, no DB changes needed
418
+
419
+ Load the specification into Codex, discuss the addition, and have it update the specification, generate the code and run verification tests.
420
+
421
+ ---
422
+
423
+ Apache License 2.0 — Copyright (C) 2026 NeuralNexusNote™ / ArnolfJp019
424
+ See [LICENSE](./LICENSE) for details.
@@ -0,0 +1,16 @@
1
+ n3memorycore_free_codex/__init__.py,sha256=-WwIpa68zS-CulIvRldLdDLIWcFP8cadg3C8EwD6Da8,58
2
+ n3memorycore_free_codex/codex_entry.py,sha256=BZ9fcBDhBP4I0YCZNcK41_yafcLwXZp1ALwQZYyJRdM,8425
3
+ n3memorycore_free_codex/codex_install.py,sha256=vJAa1OIBFls-6EzoTGoskEpFduBXcETnc5LrnZySlbc,5118
4
+ n3memorycore_free_codex/n3memory.py,sha256=22nCm-dpBxqAjGwscAuld6S9ipTbs8g6uu5mvz0_X9k,73243
5
+ n3memorycore_free_codex/paths.py,sha256=eMrP6Ydx_v5Cqiw7D23KiY-YCSRGvWHW4t8SEtkaumU,1120
6
+ n3memorycore_free_codex/project.py,sha256=4oSqNObiPPjKMU50j4jYJXCVdQzz6iPVdEo6h38Xg_k,705
7
+ n3memorycore_free_codex/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
+ n3memorycore_free_codex/core/database.py,sha256=dF54gkQC6wKTsjFtnWMLgDyCfIQIhgxDKOu24WEwxkw,16927
9
+ n3memorycore_free_codex/core/processor.py,sha256=OtHIaDwObxtYo2pG4qCkHJQIaVOtT5b6UduPRs1sUiQ,23599
10
+ n3memorycore_free_codex-1.9.2.dist-info/licenses/LICENSE,sha256=M2YzHY1a93-rLzWpSibYAPq22hPFlN0MtlOPXN1CnIM,10780
11
+ n3memorycore_free_codex-1.9.2.dist-info/licenses/NOTICE,sha256=jRvtRt5JlE2L389Tx_Xqpgvw_QLLQPNfw9yrefE1mZA,119
12
+ n3memorycore_free_codex-1.9.2.dist-info/METADATA,sha256=cQQTUS8KOA_togevrF8BXxjBfKxVsfPzxYrIOcI0MYQ,27806
13
+ n3memorycore_free_codex-1.9.2.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
14
+ n3memorycore_free_codex-1.9.2.dist-info/entry_points.txt,sha256=fS8oialZqWEwZ_yFu-NSOLH2E_rQgrV3r2pU1PpXNpk,219
15
+ n3memorycore_free_codex-1.9.2.dist-info/top_level.txt,sha256=5ZQ7b9POnsi8J7J95MdkMJMr5cNa6A-WIfRDv3b_vh4,24
16
+ n3memorycore_free_codex-1.9.2.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,4 @@
1
+ [console_scripts]
2
+ n3mc-free-codex = n3memorycore_free_codex.n3memory:main
3
+ n3mc-free-codex-hook = n3memorycore_free_codex.codex_entry:prompt_main
4
+ n3mc-free-codex-stop-hook = n3memorycore_free_codex.codex_entry:stop_main