teammind 0.1.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.
package/README.md ADDED
@@ -0,0 +1,366 @@
1
+ <div align="center">
2
+
3
+ ```
4
+ ████████╗███████╗ █████╗ ███╗ ███╗███╗ ███╗██╗███╗ ██╗██████╗
5
+ ██╔══╝██╔════╝██╔══██╗████╗ ████║████╗ ████║██║████╗ ██║██╔══██╗
6
+ ██║ █████╗ ███████║██╔████╔██║██╔████╔██║██║██╔██╗ ██║██║ ██║
7
+ ██║ ██╔══╝ ██╔══██║██║╚██╔╝██║██║╚██╔╝██║██║██║╚██╗██║██║ ██║
8
+ ██║ ███████╗██║ ██║██║ ╚═╝ ██║██║ ╚═╝ ██║██║██║ ╚████║██████╔╝
9
+ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝╚═╝╚═╝ ╚═══╝╚═════╝
10
+ ```
11
+
12
+ **Git-aware persistent memory for Claude Code teams**
13
+
14
+ [![npm version](https://img.shields.io/npm/v/teammind?color=blue&style=flat-square)](https://npmjs.com/package/teammind)
15
+ [![Node.js](https://img.shields.io/badge/node-%3E%3D18.0.0-green?style=flat-square)](https://nodejs.org)
16
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg?style=flat-square)](LICENSE)
17
+ [![Claude Code](https://img.shields.io/badge/Claude%20Code-compatible-purple?style=flat-square)](https://claude.ai/code)
18
+
19
+ *Every insight your team discovers with Claude Code — remembered forever.*
20
+
21
+ </div>
22
+
23
+ ---
24
+
25
+ ## The problem
26
+
27
+ Claude Code is stateless. Every session starts fresh.
28
+
29
+ Alice spends 3 hours debugging a race condition, discovers the root cause, fixes it. Bob hits the exact same bug the next morning — his Claude has no idea what Alice learned. The senior dev who knows why the auth middleware skips OPTIONS requests goes on vacation. The codebase has 40 undocumented gotchas that only exist in old conversations.
30
+
31
+ **TeamMind fixes this.** It silently captures what your team learns in Claude Code sessions and makes that knowledge available to every developer's Claude — automatically, forever.
32
+
33
+ ---
34
+
35
+ ## How it works
36
+
37
+ ```
38
+ YOUR SESSION BACKGROUND
39
+ ────────────────── ──────────────────────────────────
40
+ You open Claude Code
41
+
42
+
43
+ SessionStart hook fires
44
+ TeamMind injects team
45
+ context into Claude's
46
+ initial prompt
47
+ ┌─────────────────────┐
48
+ │ [gotcha] Auth skips │
49
+ │ OPTIONS for CORS │
50
+ │ [bug] Prisma times │
51
+ │ out at 5s on large │
52
+ │ checkouts │
53
+ └─────────────────────┘
54
+
55
+ Claude already knows
56
+ before you type a word
57
+
58
+
59
+ Mid-session: Claude calls
60
+ memory_search / memory_add
61
+ as it encounters files
62
+ │ SESSION ENDS
63
+ ▼ │
64
+ You close Claude Code ──────────────────────►│
65
+
66
+ Stop hook fires
67
+ Transcript saved to DB
68
+
69
+ ▼ (fully detached)
70
+ claude-haiku-4-5 reads
71
+ the transcript, extracts
72
+ high-value memories
73
+
74
+
75
+ Memories embedded locally
76
+ Stored with git metadata
77
+ File hashes saved for
78
+ staleness detection
79
+ ```
80
+
81
+ ---
82
+
83
+ ## Install
84
+
85
+ **One command. 30 seconds.**
86
+
87
+ ```bash
88
+ npx teammind init
89
+ ```
90
+
91
+ ```
92
+ ✓ Claude Code detected (v2.1.59)
93
+ ✓ Hooks installed in ~/.claude/settings.json
94
+ ✓ MCP server registered
95
+ ✓ Embedding model ready (38MB, runs locally)
96
+ ✓ Database created at ~/.teammind/db.sqlite
97
+
98
+ TeamMind is active. Just use Claude Code normally.
99
+ ```
100
+
101
+ That's it. No API key required for the core feature. No server to run. No config to write.
102
+
103
+ > **Optional:** Set `ANTHROPIC_API_KEY` to enable automatic memory extraction at session end (~$0.001/session). Without it, you can still add memories manually via Claude during sessions.
104
+
105
+ ---
106
+
107
+ ## Features
108
+
109
+ | | |
110
+ |---|---|
111
+ | **Silent operation** | Injects memory context before your first prompt. Captures learnings after your last. You never see it working. |
112
+ | **Git-aware** | Memories are tagged with branch and commit. Files referenced by a memory are hashed — when those files change, the memory is marked stale automatically. |
113
+ | **Zero native deps** | Uses Node.js built-in `node:sqlite`. No compilation, no Visual Studio, no Python. Works on Mac, Linux, and Windows out of the box. |
114
+ | **Local-first** | Embeddings run in-process. Your code never leaves your machine unless you explicitly choose cloud sync. |
115
+ | **Team sync** | Export memories to a JSON file, commit it to your repo, teammates import on `git pull`. |
116
+ | **MCP tools** | Claude can search, add, and check memory freshness mid-session via 4 MCP tools. |
117
+
118
+ ---
119
+
120
+ ## CLI Reference
121
+
122
+ ```bash
123
+ # Setup
124
+ npx teammind init # one-time setup — patches Claude Code settings
125
+
126
+ # Daily use
127
+ teammind status # memory stats for the current project
128
+ teammind memories # browse all memories
129
+ teammind memories "auth" # search memories by keyword
130
+ teammind sessions # see captured sessions (processed / pending)
131
+ teammind forget <id> # delete a specific memory
132
+ teammind forget --stale # bulk-delete all stale memories
133
+
134
+ # Extraction
135
+ teammind extract --pending # manually trigger extraction for pending sessions
136
+ teammind config set ANTHROPIC_API_KEY sk-... # set API key for auto-extraction
137
+
138
+ # Team sync
139
+ teammind team # interactive team setup wizard
140
+ teammind team --export ./path # export memories to JSON
141
+ teammind team --import ./path # import memories from JSON
142
+ ```
143
+
144
+ ---
145
+
146
+ ## What gets remembered
147
+
148
+ TeamMind uses `claude-haiku-4-5` to read your session transcript and extract only memories worth keeping:
149
+
150
+ | Captured | Not captured |
151
+ |---|---|
152
+ | Bugs found and their root cause | Generic programming advice |
153
+ | Architectural decisions and *why* | Things obvious from reading the code |
154
+ | Non-obvious gotchas | Temporary debugging steps |
155
+ | API quirks and workarounds | Standard library usage |
156
+ | Performance findings | Basic code explanations |
157
+ | Security considerations | |
158
+ | Important config constraints | |
159
+
160
+ Each memory is stored with:
161
+ - The files it relates to (for staleness detection)
162
+ - The git commit and branch it was discovered on
163
+ - Who discovered it
164
+ - A semantic embedding (for smart retrieval)
165
+
166
+ ---
167
+
168
+ ## Team Sync
169
+
170
+ ### Option 1: Git (recommended)
171
+
172
+ ```bash
173
+ # On your machine
174
+ teammind team --export .claude/team-memories.json
175
+ git add .claude/team-memories.json
176
+ git commit -m "chore: add team memories"
177
+ git push
178
+
179
+ # On your teammate's machine
180
+ git pull
181
+ teammind team --import .claude/team-memories.json
182
+ ```
183
+
184
+ Auto-import on every `git pull` with a post-merge hook:
185
+ ```bash
186
+ echo 'teammind team --import .claude/team-memories.json' >> .git/hooks/post-merge
187
+ chmod +x .git/hooks/post-merge
188
+ ```
189
+
190
+ ### Option 2: Self-hosted sync *(coming soon)*
191
+
192
+ Run a sync server on your own infra. All team members point to it.
193
+
194
+ ### Option 3: TeamMind Cloud *(coming soon)*
195
+
196
+ Hosted sync, free for teams under 5.
197
+
198
+ ---
199
+
200
+ ## Configuration
201
+
202
+ ```bash
203
+ # Set your Anthropic API key (enables auto-extraction)
204
+ teammind config set ANTHROPIC_API_KEY sk-ant-...
205
+
206
+ # View all config
207
+ teammind config list
208
+
209
+ # Adjust injection (default: 10 memories per session start)
210
+ teammind config set max_inject 15
211
+
212
+ # Disable auto-extraction (manual memory_add only)
213
+ teammind config set extraction_enabled false
214
+ ```
215
+
216
+ Config is stored at `~/.teammind/config.json`.
217
+
218
+ ---
219
+
220
+ ## Memory lifecycle
221
+
222
+ ```
223
+ Session ends
224
+
225
+
226
+ Transcript saved to ~/.teammind/db.sqlite
227
+
228
+ ▼ (background process, ~5 seconds)
229
+ Haiku reads transcript
230
+ Extracts 0–10 high-value memories
231
+
232
+
233
+ Each memory is:
234
+ • Embedded locally (all-MiniLM-L6-v2, 384 dims)
235
+ • Tagged with file paths + function names
236
+ • Hashed against current file contents
237
+ • Stored with git metadata
238
+
239
+
240
+ Next session start:
241
+ Top 10 memories injected into Claude's context
242
+ File hashes checked → stale memories flagged
243
+ Claude calls memory_search as needed
244
+ ```
245
+
246
+ ---
247
+
248
+ ## What Claude sees
249
+
250
+ At the start of every session on a project with memories:
251
+
252
+ ```xml
253
+ <team_memory project="myapp" branch="feature/payments">
254
+ 1. [gotcha] Stripe webhook must receive raw Buffer body before constructEvent() — src/webhooks/stripe.ts
255
+ 2. [decision] Using idempotency keys on all payment intents — decided after double-charge incident Jan 2026
256
+ 3. [bug] Prisma transaction timeout at 5s hits on large cart checkouts — src/db/checkout.ts
257
+ 4. [pattern] All currency stored as integers (cents), never floats
258
+ 5. [config] TEST_MODE=true bypasses Stripe in dev, but still hits real webhooks endpoint
259
+ </team_memory>
260
+ (5 of 31 memories — use memory_search tool for more)
261
+ ```
262
+
263
+ Claude reads this before you type a word. It uses `memory_search` mid-session to pull deeper context when it needs it.
264
+
265
+ ---
266
+
267
+ ## Privacy
268
+
269
+ - **Your code never leaves your machine** unless you explicitly use team export or cloud sync
270
+ - **Embeddings run locally** using `@huggingface/transformers` — no API calls for search
271
+ - **Extraction uses Haiku** at session end (if `ANTHROPIC_API_KEY` is set) — only the conversation transcript is sent, not your code
272
+ - **Team export** scans for secrets before writing (API keys, tokens, passwords are redacted)
273
+ - **Self-hostable** — run everything on your own infra if needed
274
+
275
+ ---
276
+
277
+ ## How it hooks into Claude Code
278
+
279
+ TeamMind adds two hooks and one MCP server to `~/.claude/settings.json`:
280
+
281
+ ```json
282
+ {
283
+ "hooks": {
284
+ "SessionStart": [{ "hooks": [{ "type": "command", "command": "node ... inject" }] }],
285
+ "Stop": [{ "hooks": [{ "type": "command", "command": "node ... capture" }] }]
286
+ },
287
+ "mcpServers": {
288
+ "teammind": { "type": "stdio", "command": "node", "args": ["...", "server"] }
289
+ }
290
+ }
291
+ ```
292
+
293
+ **SessionStart** runs before your first prompt and prints team memories to stdout — Claude Code injects this as context.
294
+
295
+ **Stop** fires when Claude finishes. It saves the transcript and spawns a detached background process for extraction. You feel zero latency.
296
+
297
+ **MCP server** gives Claude 4 tools: `memory_search`, `memory_add`, `memory_list`, `memory_stale`.
298
+
299
+ ---
300
+
301
+ ## MCP Tools
302
+
303
+ Claude has these tools available mid-session:
304
+
305
+ #### `memory_search`
306
+ ```
307
+ Search team memory for relevant context about code, bugs, decisions, or patterns.
308
+ Parameters: query (string), file_path? (string), limit? (number)
309
+ ```
310
+
311
+ #### `memory_add`
312
+ ```
313
+ Save an important insight, decision, bug fix, or pattern to team memory.
314
+ Parameters: content (string), summary (string), tags? (string[]), file_paths? (string[]), functions? (string[])
315
+ ```
316
+
317
+ #### `memory_list`
318
+ ```
319
+ List recent memories for the current project.
320
+ Parameters: limit? (number)
321
+ ```
322
+
323
+ #### `memory_stale`
324
+ ```
325
+ Check which memories may be outdated because their referenced files changed.
326
+ Parameters: (none)
327
+ ```
328
+
329
+ ---
330
+
331
+ ## Staleness detection
332
+
333
+ When TeamMind saves a memory that references a file, it stores a SHA-256 hash of that file at that moment.
334
+
335
+ Every session start, it re-hashes all referenced files and compares. If a file changed:
336
+ - The memory is marked `stale`
337
+ - It still injects with a `[may be outdated]` tag
338
+ - It's deprioritized in ranking
339
+ - `teammind forget --stale` clears them in bulk
340
+
341
+ This means memories about refactored code don't silently mislead future sessions.
342
+
343
+ ---
344
+
345
+ ## Requirements
346
+
347
+ - Node.js ≥ 18.0.0
348
+ - Claude Code (any version with hooks support)
349
+ - Git (for git-aware features)
350
+ - `ANTHROPIC_API_KEY` (optional — only for auto-extraction)
351
+
352
+ ---
353
+
354
+ ## License
355
+
356
+ MIT — use it, fork it, build on it.
357
+
358
+ ---
359
+
360
+ <div align="center">
361
+
362
+ Built for teams who use Claude Code seriously.
363
+
364
+ [npm](https://npmjs.com/package/teammind) · [Issues](https://github.com/yourusername/teammind/issues)
365
+
366
+ </div>
package/dist/cli.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};