total-recall-memory 1.3.0

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,21 @@
1
+ {
2
+ "name": "total-recall",
3
+ "owner": {
4
+ "name": "Radu Lupu"
5
+ },
6
+ "plugins": [
7
+ {
8
+ "name": "total-recall",
9
+ "source": "./",
10
+ "description": "Persistent cross-session memory for Claude Code. Automatically stores decisions, patterns, and lessons learned in a semantic search index so every session starts with full context. Supports multi-machine sharing via HTTP server with web UI.",
11
+ "version": "1.3.0",
12
+ "author": {
13
+ "name": "Radu Lupu"
14
+ },
15
+ "homepage": "https://github.com/radu2lupu/total-recall",
16
+ "repository": "https://github.com/radu2lupu/total-recall",
17
+ "license": "MIT",
18
+ "keywords": ["memory", "knowledge", "semantic-search", "sessions", "qmd", "multi-machine", "cross-session", "persistence"]
19
+ }
20
+ ]
21
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "name": "total-recall",
3
+ "description": "Persistent cross-session memory for Claude Code. Automatically stores decisions, patterns, and lessons learned in a semantic search index so every session starts with full context. Supports multi-machine sharing via HTTP server with web UI.",
4
+ "author": {
5
+ "name": "Radu Lupu"
6
+ }
7
+ }
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Radu Lupu
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.
package/README.md ADDED
@@ -0,0 +1,183 @@
1
+ # total-recall
2
+
3
+ Persistent cross-session memory for Claude Code. Stores decisions, patterns, and lessons learned in a semantic search index (qmd) so every new session starts with full context of past work.
4
+
5
+ Works on a single machine with iCloud backup, or across multiple machines via a built-in HTTP server with a web UI for browsing and editing memories.
6
+
7
+ ## Quick Start
8
+
9
+ ### Claude Code Plugin (recommended)
10
+
11
+ ```text
12
+ /install radu2lupu/total-recall
13
+ ```
14
+
15
+ Then run `/memory-setup` inside any project to configure it.
16
+
17
+ ### npm
18
+
19
+ ```bash
20
+ npm install -g total-recall-memory
21
+ total-recall install --project my-project
22
+ ```
23
+
24
+ ### From source
25
+
26
+ ```bash
27
+ git clone https://github.com/radu2lupu/total-recall.git
28
+ cd total-recall
29
+ ./scripts/install.sh --project my-project
30
+ ```
31
+
32
+ ## What It Does
33
+
34
+ Once installed, memory is fully automatic:
35
+
36
+ - **Session start**: Claude queries past memories for relevant context before starting work
37
+ - **Session end**: Claude writes a summary of what was done, decisions made, and lessons learned
38
+ - **Mid-session**: Claude queries memory when encountering problems where prior context could help
39
+
40
+ No manual commands needed. Three enforcement layers make this reliable:
41
+
42
+ 1. **SessionStart hook** — fires before Claude sees the user's message, forcing a memory query as the first action
43
+ 2. **CLAUDE.md instructions** — detailed rules for when to query and when to write
44
+ 3. **Stop hook** — blocks session end until a memory summary is written
45
+
46
+ ## Architecture
47
+
48
+ ```
49
+ ~/.ai-memory/knowledge/<project>/
50
+ ├── sessions/ # Session summaries (auto-generated)
51
+ │ ├── 2025-06-15-auth-refactor.md
52
+ │ └── imported/ # Ingested from Claude/Codex logs
53
+ │ ├── claude/
54
+ │ └── codex/
55
+ ├── decisions/ # Architectural decisions
56
+ ├── patterns/ # Reusable patterns
57
+ ├── bugs/ # Bug investigations
58
+ └── MEMORY.md # Project-level notes
59
+ ```
60
+
61
+ Each memory file contains structured metadata — date, machine, project, topic — and is indexed by qmd for hybrid BM25 + vector search.
62
+
63
+ ## Multi-Machine Setup
64
+
65
+ Share memories across machines on the same network using the built-in HTTP server. One command per machine.
66
+
67
+ ### On the server machine
68
+
69
+ ```bash
70
+ ./scripts/install.sh --project my-project --server
71
+ ```
72
+
73
+ This does everything: local memory setup, iCloud backup, session ingestion, hooks, **and** starts an HTTP server on port 7899 with auto-restart on boot. It prints the API key and client connection command.
74
+
75
+ ### On client machines
76
+
77
+ ```bash
78
+ ./scripts/install.sh --project my-project --client \
79
+ --server-url http://server.tailscale:7899 \
80
+ --api-key tr_sk_...
81
+ ```
82
+
83
+ Client installs are lightweight — no local qmd or memory directories needed. Just the CLI, hooks, and instruction injection. All `write` and `query` operations route to the server automatically.
84
+
85
+ ### Web UI
86
+
87
+ The server includes a web UI at `http://server:7899/` for browsing, viewing, editing, and deleting memories. Memories are grouped by project with metadata pills showing date, machine, and source tool.
88
+
89
+ ### Manual server/client commands
90
+
91
+ For more control, the individual commands are still available:
92
+
93
+ ```bash
94
+ total-recall server init # Generate config + API key
95
+ total-recall server start # Start server manually
96
+ total-recall server stop # Stop server
97
+ total-recall server status # Check server status
98
+ total-recall server add-key # Generate additional API key
99
+ total-recall server install-launchd # Auto-start on boot (macOS)
100
+
101
+ total-recall client configure --server-url URL --api-key KEY
102
+ total-recall client status # Check connection
103
+ total-recall client enable # Re-enable remote mode
104
+ total-recall client disable # Switch back to local mode
105
+ ```
106
+
107
+ ## All Commands
108
+
109
+ ```
110
+ # Install (three modes)
111
+ total-recall install --project NAME Standalone: full local setup
112
+ total-recall install --project NAME --server Server: local + HTTP API + launchd
113
+ total-recall install --project NAME --client --server-url URL --api-key KEY Client: remote only
114
+
115
+ # Core
116
+ total-recall write --project NAME "<summary>" Write a memory note
117
+ total-recall query --project NAME "<query>" Semantic search across memories
118
+ total-recall ingest --project NAME Import Claude/Codex session logs
119
+ total-recall status --project NAME Show memory stats and config
120
+
121
+ # iCloud
122
+ total-recall icloud-enable --project NAME Move memory to iCloud Drive
123
+ total-recall icloud-sync --project NAME Manual iCloud push/pull
124
+ total-recall icloud-status --project NAME Check iCloud sync state
125
+
126
+ # Server management
127
+ total-recall server init / start / stop / status / add-key / install-launchd
128
+
129
+ # Client management
130
+ total-recall client configure / status / enable / disable
131
+ ```
132
+
133
+ ### Plugin Slash Commands
134
+
135
+ When installed as a Claude Code plugin:
136
+
137
+ - `/memory-setup` — Interactive setup wizard for the current project
138
+ - `/memory-write` — Write a session summary to memory
139
+ - `/memory-rebuild` — Rebuild memory from git history and Codex sessions
140
+
141
+ ## Install Options
142
+
143
+ ```bash
144
+ # Standalone options
145
+ total-recall install --project my-project --no-icloud # Skip iCloud backup
146
+ total-recall install --project my-project --no-launch-agent # Skip background sync
147
+ total-recall install --project my-project --interval-minutes 10 # Sync every 10 min
148
+ total-recall install --project my-project --skip-embed # Skip vector embeddings
149
+
150
+ # Server options
151
+ total-recall install --project my-project --server --port 8080 # Custom port
152
+
153
+ # Client (no local qmd or bun needed)
154
+ total-recall install --project my-project --client \
155
+ --server-url http://server:7899 --api-key tr_sk_...
156
+ ```
157
+
158
+ ## Environment Variables
159
+
160
+ | Variable | Default | Purpose |
161
+ |----------|---------|---------|
162
+ | `TOTAL_RECALL_SHARED_ROOT` | `~/.ai-memory/knowledge` | Base directory for all project memories |
163
+ | `TOTAL_RECALL_ICLOUD_ROOT` | `~/Library/Mobile Documents/.../AI-Memory/knowledge` | iCloud sync directory |
164
+ | `TOTAL_RECALL_STATE_ROOT` | `~/.ai-memory/state` | Ingestion state tracking |
165
+ | `TOTAL_RECALL_SERVER_URL` | — | Override client server URL |
166
+ | `TOTAL_RECALL_API_KEY` | — | Override client API key |
167
+ | `TOTAL_RECALL_SYNC_INTERVAL_MINUTES` | `15` | Background sync interval |
168
+
169
+ ## Requirements
170
+
171
+ **Standalone / Server:**
172
+ - macOS (iCloud + launchd features are macOS-only; core memory works anywhere)
173
+ - [bun](https://bun.sh) (for installing qmd)
174
+ - [qmd](https://github.com/tobi/qmd) (installed automatically)
175
+ - Python 3.8+ (for server and session ingestion)
176
+
177
+ **Client only:**
178
+ - Python 3.8+ (for CLI)
179
+ - No bun or qmd needed — everything routes to the server
180
+
181
+ ## License
182
+
183
+ MIT
@@ -0,0 +1,100 @@
1
+ ---
2
+ description: "Rebuild session memory from git history and optionally Codex sessions"
3
+ allowed-tools: [Bash, Write, Read, Glob, Grep]
4
+ argument-hint: "[--since YYYY-MM-DD] [--codex]"
5
+ ---
6
+
7
+ # Rebuild Session Memory
8
+
9
+ Reconstruct the full session history from git commits and optionally from OpenAI Codex CLI session logs.
10
+
11
+ ## Context
12
+
13
+ - Project root: !`git -C "$PWD" rev-parse --show-toplevel 2>/dev/null || echo "$PWD"`
14
+ - Project name: !`basename "$(git -C "$PWD" remote get-url origin 2>/dev/null | sed 's/.*\///' | sed 's/\.git$//')" 2>/dev/null || basename "$PWD"`
15
+ - Knowledge dir: !`PROJECT=$(basename "$(git remote get-url origin 2>/dev/null | sed 's/.*\///' | sed 's/\.git$//')" 2>/dev/null || basename "$PWD"); echo "$HOME/.claude/knowledge/$PROJECT"`
16
+ - Git log summary: !`git log --oneline --since="2025-01-01" | wc -l` commits since 2025
17
+ - Existing session files: !`PROJECT=$(basename "$(git remote get-url origin 2>/dev/null | sed 's/.*\///' | sed 's/\.git$//')" 2>/dev/null || basename "$PWD"); ls "$HOME/.claude/knowledge/$PROJECT/sessions/" 2>/dev/null | wc -l` files
18
+ - Codex sessions exist: !`ls ~/.codex/sessions/ 2>/dev/null && echo "yes" || echo "no"`
19
+ - Arguments: $ARGUMENTS
20
+
21
+ ## Your Task
22
+
23
+ Use the detected project name and knowledge directory from the context above.
24
+
25
+ ### 1. Parse Arguments
26
+
27
+ - `--since YYYY-MM-DD`: Only rebuild from this date forward (default: all history)
28
+ - `--codex`: Also parse Codex CLI `.jsonl` session files from `~/.codex/sessions/`
29
+
30
+ ### 2. Analyze Git History
31
+
32
+ ```bash
33
+ git log --format="%H %ai %s" --since="<date>"
34
+ ```
35
+
36
+ Group commits into logical sessions by:
37
+ - Date proximity (same day = same session usually)
38
+ - Topic coherence (related commit messages)
39
+ - Author patterns (structured `feat/fix/chore` commits vs informal)
40
+
41
+ ### 3. Parse Codex Sessions (if --codex)
42
+
43
+ For each `.jsonl` file in `~/.codex/sessions/` (and `~/.codex/archived_sessions/`):
44
+ - Extract user messages (role: "user", type: "input_text")
45
+ - Skip system instructions and environment context blocks
46
+ - Handle both old format (direct content) and new format (event_msg with payload)
47
+ - Group by session file (each file = one session)
48
+
49
+ Use this Python extraction pattern:
50
+ ```python
51
+ import sys, json
52
+ for line in sys.stdin:
53
+ try:
54
+ obj = json.loads(line.strip())
55
+ if obj.get('role') == 'user':
56
+ for c in obj.get('content', []):
57
+ text = c.get('text', '')
58
+ if text and not text.startswith('<user_instructions>') and not text.startswith('<environment_context>'):
59
+ print(text[:500])
60
+ except: pass
61
+ ```
62
+
63
+ ### 4. Write Session Files
64
+
65
+ For each identified session, write to `<knowledge-dir>/sessions/YYYY-MM-DD-<topic>.md` using the standard template:
66
+
67
+ ```markdown
68
+ # Session: [Brief Title]
69
+
70
+ **Date:** YYYY-MM-DD
71
+ **Machine:** !`scutil --get ComputerName 2>/dev/null || hostname -s`
72
+ **Topic:** [Category — specific area]
73
+ **Tool:** [Claude Code / Codex CLI / Cursor / Manual]
74
+
75
+ ## What Was Done
76
+ - [Bullet points]
77
+
78
+ ## Decisions Made
79
+ - [Choices and reasoning]
80
+
81
+ ## Lessons Learned
82
+ - [Gotchas and insights]
83
+ ```
84
+
85
+ Rules:
86
+ - Don't overwrite existing session files — skip dates that already have files
87
+ - For Codex sessions, note the tool as "OpenAI Codex CLI"
88
+ - For Cursor PRs (cursor/ branch prefixes), note as "Cursor"
89
+ - Group small related sessions on the same day into one file
90
+ - Use concise but informative descriptions
91
+
92
+ ### 5. Re-index and Embed
93
+
94
+ ```bash
95
+ qmd update && qmd embed
96
+ ```
97
+
98
+ ### 6. Report
99
+
100
+ Tell the user how many session files were created/updated and the total knowledge base size.
@@ -0,0 +1,94 @@
1
+ ---
2
+ description: "Set up total-recall memory for the current project"
3
+ allowed-tools: [Bash, Read, Write, Glob]
4
+ ---
5
+
6
+ # Total Recall Setup
7
+
8
+ Set up cross-session semantic memory for the current project. This runs the full `total-recall install` — shared memory, session ingestion, qmd indexing, and background sync.
9
+
10
+ ## Context
11
+
12
+ - Current directory: !`pwd`
13
+ - Git remote: !`git remote get-url origin 2>/dev/null || echo "no git remote"`
14
+ - Detected project name: !`basename "$(git remote get-url origin 2>/dev/null | sed 's/.*\///' | sed 's/\.git$//')" 2>/dev/null || basename "$PWD"`
15
+ - Platform: !`uname -s`
16
+ - iCloud Drive exists: !`[ -d "$HOME/Library/Mobile Documents/com~apple~CloudDocs" ] && echo "yes" || echo "no"`
17
+ - qmd installed: !`command -v qmd >/dev/null 2>&1 && echo "yes" || echo "no"`
18
+ - bun installed: !`command -v bun >/dev/null 2>&1 && echo "yes" || echo "no"`
19
+ - Plugin root: !`echo "${CLAUDE_PLUGIN_ROOT:-unknown}"`
20
+ - Client configured: !`[ -f "$HOME/.ai-memory/client.json" ] && echo "yes" || echo "no"`
21
+ - Server configured: !`[ -f "$HOME/.ai-memory/server.json" ] && echo "yes" || echo "no"`
22
+ - User arguments: $ARGUMENTS
23
+
24
+ ## Your Task
25
+
26
+ ### 1. Pre-flight check
27
+
28
+ If `qmd` is not installed and `bun` is not installed either, stop and tell the user:
29
+ ```
30
+ Install bun first: curl -fsSL https://bun.sh/install | bash
31
+ Then re-run /memory-setup
32
+ ```
33
+
34
+ If `bun` is available but `qmd` is not, install it:
35
+ ```bash
36
+ bun install -g github:tobi/qmd
37
+ ```
38
+
39
+ ### 2. Ask the user (interactive)
40
+
41
+ Ask the user these questions **before** running anything. Present them all at once so the user can answer in one go.
42
+
43
+ **Project name:** Show the auto-detected name from context above. Ask if it's correct or if they want a different name. If the user provided a name via `$ARGUMENTS`, use that without asking.
44
+
45
+ **iCloud backup:** Only ask on macOS when iCloud Drive exists. Default yes. Explain: "This syncs your memory to iCloud so it survives machine changes."
46
+
47
+ **Background sync:** Only ask on macOS. Default yes. Explain: "This installs a background job that imports new Claude/Codex session logs every 15 minutes."
48
+
49
+ **Multi-machine mode:** If no server or client is configured, ask if this machine should:
50
+ - **Standalone** (default) — memory stays local (with optional iCloud)
51
+ - **Server** — this machine hosts a total-recall HTTP server that other machines connect to
52
+ - **Client** — this machine connects to an existing total-recall server
53
+
54
+ ### 3. Run total-recall install
55
+
56
+ Build the command from the user's answers:
57
+
58
+ ```bash
59
+ <plugin-root>/scripts/total-recall install \
60
+ --project <project-name> \
61
+ [--no-icloud] \
62
+ [--no-launch-agent]
63
+ ```
64
+
65
+ Where `<plugin-root>` is the Plugin root from context above. Run it and let the output stream.
66
+
67
+ ### 4. Multi-machine setup (if selected)
68
+
69
+ **If Server:**
70
+ ```bash
71
+ <plugin-root>/scripts/total-recall server init
72
+ <plugin-root>/scripts/total-recall server start
73
+ ```
74
+ Tell the user their API key and server URL. Ask if they want to auto-start on boot:
75
+ ```bash
76
+ <plugin-root>/scripts/total-recall server install-launchd
77
+ ```
78
+
79
+ **If Client:**
80
+ Ask the user for the server URL and API key, then:
81
+ ```bash
82
+ <plugin-root>/scripts/total-recall client configure \
83
+ --server-url <url> \
84
+ --api-key <key>
85
+ ```
86
+
87
+ ### 5. Report results
88
+
89
+ Tell the user:
90
+ - Setup is complete
91
+ - Memory is fully automatic — Claude will query past memories at session start and save new ones at session end, no manual commands needed
92
+ - If server mode: share the server URL and API key with other machines, and mention the web UI at `http://<server>:7899/`
93
+ - If client mode: confirm the connection is active with `total-recall client status`
94
+ - `/memory-rebuild` can optionally backfill memory from git history if they want to seed it with past work
@@ -0,0 +1,69 @@
1
+ ---
2
+ description: "Write a session summary to qmd memory"
3
+ model: sonnet
4
+ allowed-tools: [Bash, Write, Read, Glob, Grep]
5
+ ---
6
+
7
+ # Write Session Memory
8
+
9
+ Write a summary of the current session's work to the qmd knowledge base.
10
+
11
+ ## Context
12
+
13
+ - Today's date: !`date +%Y-%m-%d`
14
+ - Project root: !`git -C "$PWD" rev-parse --show-toplevel 2>/dev/null || echo "$PWD"`
15
+ - Project name: !`basename "$(git -C "$PWD" remote get-url origin 2>/dev/null | sed 's/.*\///' | sed 's/\.git$//')" 2>/dev/null || basename "$PWD"`
16
+ - Knowledge dir: !`PROJECT=$(basename "$(git remote get-url origin 2>/dev/null | sed 's/.*\///' | sed 's/\.git$//')" 2>/dev/null || basename "$PWD"); echo "$HOME/.claude/knowledge/$PROJECT"`
17
+ - Recent commits (last 24h): !`git log --oneline --since="24 hours ago" 2>/dev/null || echo "no recent commits"`
18
+ - Uncommitted changes: !`git diff --stat HEAD 2>/dev/null || echo "no changes"`
19
+ - Untracked files: !`git ls-files --others --exclude-standard 2>/dev/null | head -10`
20
+ - Latest session file: !`PROJECT=$(basename "$(git remote get-url origin 2>/dev/null | sed 's/.*\///' | sed 's/\.git$//')" 2>/dev/null || basename "$PWD"); ls -t "$HOME/.claude/knowledge/$PROJECT/sessions/" 2>/dev/null | head -1`
21
+ - User request: $ARGUMENTS
22
+
23
+ ## Your Task
24
+
25
+ Write a session summary capturing what was done in this session. Use the detected project name and knowledge directory from the context above.
26
+
27
+ ### 1. Determine What Was Done
28
+
29
+ Analyze the git log, diffs, and any context from the conversation to understand what work was completed. If the user provided a description via `$ARGUMENTS`, use that as the primary source.
30
+
31
+ ### 2. Generate Session File
32
+
33
+ Write the summary to `<knowledge-dir>/sessions/YYYY-MM-DD-<topic>.md` using this template:
34
+
35
+ ```markdown
36
+ # Session: [Brief Title]
37
+
38
+ **Date:** YYYY-MM-DD
39
+ **Machine:** !`scutil --get ComputerName 2>/dev/null || hostname -s`
40
+ **Topic:** [Category — specific area]
41
+
42
+ ## What Was Done
43
+ - [Bullet points of completed work]
44
+
45
+ ## Decisions Made
46
+ - [Any choices made and why]
47
+
48
+ ## Lessons Learned
49
+ - [Gotchas, insights, things to remember]
50
+ ```
51
+
52
+ Rules:
53
+ - Topic slug should be kebab-case, 2-4 words (e.g., `ingredient-display-fixes`)
54
+ - If a file for today with the same topic already exists, append a number suffix
55
+ - Be concise but capture the important details — especially decisions and lessons
56
+ - Include specific file paths, function names, or error messages that would help future sessions
57
+
58
+ ### 3. Index and Embed
59
+
60
+ Run:
61
+ ```bash
62
+ qmd update && qmd embed
63
+ ```
64
+
65
+ The `qmd embed` may crash on cleanup (known bun bug) — this is harmless.
66
+
67
+ ### 4. Confirm
68
+
69
+ Tell the user what file was written and that it's been indexed.
@@ -0,0 +1,26 @@
1
+ {
2
+ "description": "Total Recall: cross-session memory persistence via qmd",
3
+ "hooks": {
4
+ "SessionStart": [
5
+ {
6
+ "hooks": [
7
+ {
8
+ "type": "command",
9
+ "command": "${CLAUDE_PLUGIN_ROOT}/hooks/session-start-query.sh",
10
+ "statusMessage": "Loading session memory..."
11
+ }
12
+ ]
13
+ }
14
+ ],
15
+ "Stop": [
16
+ {
17
+ "hooks": [
18
+ {
19
+ "type": "command",
20
+ "command": "${CLAUDE_PLUGIN_ROOT}/hooks/session-summary-reminder.sh"
21
+ }
22
+ ]
23
+ }
24
+ ]
25
+ }
26
+ }
@@ -0,0 +1,41 @@
1
+ #!/bin/bash
2
+ # SessionStart hook — tells Claude to query Total Recall before doing anything else.
3
+ INPUT=$(cat)
4
+
5
+ # Get cwd from hook input (more reliable than $PWD in hook context)
6
+ CWD=$(echo "$INPUT" | jq -r '.cwd // empty')
7
+ CWD="${CWD:-$PWD}"
8
+
9
+ # Ensure bun-installed globals (like qmd) are on PATH
10
+ for p in "$HOME/.bun/bin" "/opt/homebrew/bin" "/usr/local/bin"; do
11
+ [ -d "$p" ] && export PATH="$p:$PATH"
12
+ done
13
+
14
+ # Extract project name from the total-recall instruction block in CLAUDE.md
15
+ # This is the most reliable source — it's set during `total-recall install`
16
+ PROJECT=""
17
+ CLAUDE_MD="$HOME/.claude/CLAUDE.md"
18
+ if [ -f "$CLAUDE_MD" ]; then
19
+ PROJECT=$(sed -n 's/.*Total Recall Auto-Memory (\([^)]*\)).*/\1/p' "$CLAUDE_MD" | head -1)
20
+ fi
21
+
22
+ # Fallback: derive from git remote or directory name
23
+ if [ -z "$PROJECT" ]; then
24
+ PROJECT=$(basename "$(git -C "$CWD" remote get-url origin 2>/dev/null | sed 's/.*\///' | sed 's/\.git$//')" 2>/dev/null || basename "$CWD")
25
+ fi
26
+
27
+ CLI="${CLAUDE_PLUGIN_ROOT}/scripts/total-recall"
28
+ KNOWLEDGE_DIR="$HOME/.ai-memory/knowledge/$PROJECT"
29
+ CLIENT_JSON="$HOME/.ai-memory/client.json"
30
+
31
+ # Activate if local qmd memory exists OR if a remote server is configured
32
+ if { [ -d "$KNOWLEDGE_DIR" ] && command -v qmd >/dev/null 2>&1; } || [ -f "$CLIENT_JSON" ]; then
33
+ jq -n --arg cli "$CLI" --arg project "$PROJECT" '{
34
+ "hookSpecificOutput": {
35
+ "hookEventName": "SessionStart",
36
+ "additionalContext": ("TOTAL RECALL MEMORY SYSTEM ACTIVE.\nYour FIRST action — before reading files, before planning, before anything — MUST be to query prior session memory:\n`" + $cli + " query --project " + $project + " \"<what the user is asking about>\"`\nThis retrieves context from all previous sessions. Without it, you will repeat past mistakes and miss prior decisions. This is mandatory, not optional.")
37
+ }
38
+ }'
39
+ fi
40
+
41
+ exit 0
@@ -0,0 +1,43 @@
1
+ #!/bin/bash
2
+ INPUT=$(cat)
3
+
4
+ # Prevent infinite loop — if we already triggered a stop hook continuation, let it end
5
+ if [ "$(echo "$INPUT" | jq -r '.stop_hook_active // false')" = "true" ]; then
6
+ exit 0
7
+ fi
8
+
9
+ # Get cwd from hook input (more reliable than $PWD in hook context)
10
+ CWD=$(echo "$INPUT" | jq -r '.cwd // empty')
11
+ CWD="${CWD:-$PWD}"
12
+
13
+ # Ensure bun-installed globals (like qmd) are on PATH
14
+ for p in "$HOME/.bun/bin" "/opt/homebrew/bin" "/usr/local/bin"; do
15
+ [ -d "$p" ] && export PATH="$p:$PATH"
16
+ done
17
+
18
+ # Extract project name from the total-recall instruction block in CLAUDE.md
19
+ # This is the most reliable source — it's set during `total-recall install`
20
+ PROJECT=""
21
+ CLAUDE_MD="$HOME/.claude/CLAUDE.md"
22
+ if [ -f "$CLAUDE_MD" ]; then
23
+ PROJECT=$(sed -n 's/.*Total Recall Auto-Memory (\([^)]*\)).*/\1/p' "$CLAUDE_MD" | head -1)
24
+ fi
25
+
26
+ # Fallback: derive from git remote or directory name
27
+ if [ -z "$PROJECT" ]; then
28
+ PROJECT=$(basename "$(git -C "$CWD" remote get-url origin 2>/dev/null | sed 's/.*\///' | sed 's/\.git$//')" 2>/dev/null || basename "$CWD")
29
+ fi
30
+
31
+ CLI="${CLAUDE_PLUGIN_ROOT}/scripts/total-recall"
32
+ KNOWLEDGE_DIR="$HOME/.ai-memory/knowledge/$PROJECT"
33
+ CLIENT_JSON="$HOME/.ai-memory/client.json"
34
+
35
+ # Activate if local qmd memory exists OR if a remote server is configured
36
+ if { [ -d "$KNOWLEDGE_DIR" ] && command -v qmd >/dev/null 2>&1; } || [ -f "$CLIENT_JSON" ]; then
37
+ jq -n --arg cli "$CLI" --arg project "$PROJECT" '{
38
+ "decision": "block",
39
+ "reason": ("BEFORE STOPPING: You must persist what you learned this session. Run:\n`" + $cli + " write --project " + $project + " \"<concise summary: what changed, why, and what was learned>\"`\nThen you may stop. If this session was truly trivial (only reading files, no changes, no decisions), you may skip this — but explain why.")
40
+ }'
41
+ else
42
+ exit 0
43
+ fi
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "total-recall-memory",
3
+ "version": "1.3.0",
4
+ "description": "Persistent cross-session memory for Claude Code. Automatically stores decisions, patterns, and lessons learned in a semantic search index so every session starts with full context. Supports multi-machine sharing via HTTP server with web UI.",
5
+ "bin": {
6
+ "total-recall": "scripts/total-recall"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "chmod +x ./scripts/total-recall ./scripts/ingest_sessions.py ./scripts/total-recall-server 2>/dev/null || true"
10
+ },
11
+ "keywords": [
12
+ "claude",
13
+ "claude-code",
14
+ "codex",
15
+ "memory",
16
+ "knowledge",
17
+ "semantic-search",
18
+ "sessions",
19
+ "qmd",
20
+ "multi-machine",
21
+ "cross-session",
22
+ "persistence",
23
+ "ai",
24
+ "llm"
25
+ ],
26
+ "author": "Radu Lupu",
27
+ "license": "MIT",
28
+ "repository": {
29
+ "type": "git",
30
+ "url": "git+https://github.com/radu2lupu/total-recall.git"
31
+ },
32
+ "homepage": "https://github.com/radu2lupu/total-recall",
33
+ "bugs": {
34
+ "url": "https://github.com/radu2lupu/total-recall/issues"
35
+ },
36
+ "os": [
37
+ "darwin",
38
+ "linux"
39
+ ],
40
+ "engines": {
41
+ "node": ">=16"
42
+ },
43
+ "files": [
44
+ "scripts/",
45
+ "hooks/",
46
+ "commands/",
47
+ ".claude-plugin/",
48
+ "LICENSE",
49
+ "README.md"
50
+ ],
51
+ "publishConfig": {
52
+ "access": "public"
53
+ }
54
+ }