coding-friend-cli 1.36.4 → 1.38.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.
Files changed (71) hide show
  1. package/README.md +8 -3
  2. package/dist/{chunk-GZT3YPAP.js → chunk-32UAW3NX.js} +1 -1
  3. package/dist/chunk-5QCGEPQO.js +238 -0
  4. package/dist/{chunk-YIXAQ4R2.js → chunk-6NXZKAOV.js} +1 -1
  5. package/dist/{chunk-XHP3EBR3.js → chunk-776ZY62N.js} +112 -4
  6. package/dist/{chunk-N4WZWRCI.js → chunk-BXSCYGWE.js} +85 -37
  7. package/dist/{chunk-AK6RMCAC.js → chunk-CGEMETKQ.js} +44 -30
  8. package/dist/{chunk-XEKQW4RN.js → chunk-ETTZRJ55.js} +1 -1
  9. package/dist/{chunk-IKLMHJH6.js → chunk-GIH6E7GJ.js} +62 -1
  10. package/dist/{chunk-56YJWGAN.js → chunk-ONG4KRYP.js} +60 -47
  11. package/dist/{chunk-X2H7JJMR.js → chunk-PLSJW7QJ.js} +29 -1
  12. package/dist/{chunk-O5ZKLFSL.js → chunk-RCE4OWNX.js} +1 -1
  13. package/dist/{chunk-K4WSC62G.js → chunk-RFNKPAJW.js} +42 -2
  14. package/dist/{clean-Q4VU662V.js → clean-YWEMYDE5.js} +3 -2
  15. package/dist/{config-CTTHWJH5.js → config-NG7SICM4.js} +15 -27
  16. package/dist/{dev-IGHMMEP4.js → dev-PTBNMKZT.js} +3 -3
  17. package/dist/{disable-HL5OEURT.js → disable-MO7AXYYF.js} +20 -3
  18. package/dist/{enable-CZIOCKKJ.js → enable-4GXLQEHD.js} +20 -3
  19. package/dist/{guide-CO2V4ZLZ.js → guide-HCR43LJN.js} +1 -1
  20. package/dist/{host-NCJMUSME.js → host-EV6QIVTI.js} +3 -3
  21. package/dist/index.js +62 -48
  22. package/dist/{init-UABKVDVT.js → init-KYE5CJMW.js} +135 -17
  23. package/dist/{install-R2HDM3N4.js → install-XAFQY5YF.js} +80 -5
  24. package/dist/{learn-K64AUUFB.js → learn-MC4VDHZH.js} +2 -2
  25. package/dist/{mcp-OMQFSJP4.js → mcp-FV6YX3ZT.js} +24 -24
  26. package/dist/{mcp-serve-3FEPFVVQ.js → mcp-serve-PXREYQRZ.js} +10 -1
  27. package/dist/{mcp-serve-learn-OF3ZJUJC.js → mcp-serve-learn-UVXIDOEZ.js} +1 -1
  28. package/dist/{memory-Y6GNALG3.js → memory-DF7OUOTV.js} +7 -7
  29. package/dist/{permission-I3OFJUYA.js → permission-VISPGMUK.js} +38 -4
  30. package/dist/{permissions-J46VP6US.js → permissions-2SBACQHV.js} +2 -2
  31. package/dist/{session-Q2DLQPYP.js → session-QK6OZO3X.js} +3 -2
  32. package/dist/{status-ML4XEDYL.js → status-FVFTJ6GS.js} +18 -14
  33. package/dist/{statusline-KKFJPTI7.js → statusline-AOZHEQSV.js} +2 -2
  34. package/dist/{uninstall-ASLHT3MH.js → uninstall-MF6FRUBO.js} +64 -3
  35. package/dist/{update-DIOH45TE.js → update-QNUCSDSA.js} +7 -4
  36. package/dist/{update-check-25SCLHZO.js → update-check-7LKJLJPM.js} +1 -1
  37. package/lib/cf-memory/src/backends/sqlite/index.ts +142 -85
  38. package/lib/cf-memory/src/lib/claude-md.ts +82 -70
  39. package/lib/cf-memory/src/lib/status-frame.ts +2 -2
  40. package/lib/cf-memory/src/tools/delete.ts +1 -1
  41. package/lib/cf-memory/src/tools/store.ts +6 -6
  42. package/lib/cf-memory/src/tools/update.ts +5 -11
  43. package/package.json +32 -4
  44. package/lib/cf-memory/README.md +0 -317
  45. package/lib/cf-memory/src/__tests__/claude-md.test.ts +0 -343
  46. package/lib/cf-memory/src/__tests__/daemon-client.test.ts +0 -146
  47. package/lib/cf-memory/src/__tests__/daemon-e2e.test.ts +0 -223
  48. package/lib/cf-memory/src/__tests__/daemon.test.ts +0 -407
  49. package/lib/cf-memory/src/__tests__/dedup.test.ts +0 -103
  50. package/lib/cf-memory/src/__tests__/embeddings.test.ts +0 -292
  51. package/lib/cf-memory/src/__tests__/lazy-install.test.ts +0 -210
  52. package/lib/cf-memory/src/__tests__/markdown-backend.test.ts +0 -450
  53. package/lib/cf-memory/src/__tests__/migration.test.ts +0 -255
  54. package/lib/cf-memory/src/__tests__/migrations.test.ts +0 -288
  55. package/lib/cf-memory/src/__tests__/minisearch-backend.test.ts +0 -262
  56. package/lib/cf-memory/src/__tests__/ollama.test.ts +0 -48
  57. package/lib/cf-memory/src/__tests__/project-id.test.ts +0 -43
  58. package/lib/cf-memory/src/__tests__/schema.test.ts +0 -128
  59. package/lib/cf-memory/src/__tests__/search.test.ts +0 -115
  60. package/lib/cf-memory/src/__tests__/status-frame.test.ts +0 -136
  61. package/lib/cf-memory/src/__tests__/temporal-decay.test.ts +0 -54
  62. package/lib/cf-memory/src/__tests__/tier.test.ts +0 -367
  63. package/lib/cf-memory/src/__tests__/tools.test.ts +0 -83
  64. package/lib/cf-memory/vitest.config.ts +0 -7
  65. package/lib/learn-host/.prettierignore +0 -4
  66. package/lib/learn-host/.prettierrc +0 -8
  67. package/lib/learn-host/README.md +0 -113
  68. package/lib/learn-host/eslint.config.mjs +0 -6
  69. package/lib/learn-mcp/README.md +0 -187
  70. package/lib/learn-mcp/src/__tests__/docs.test.ts +0 -117
  71. package/lib/learn-mcp/vitest.config.ts +0 -8
@@ -44,8 +44,8 @@ export function registerStore(
44
44
  .boolean()
45
45
  .optional()
46
46
  .describe(
47
- "When true, sync this memory to the project's CLAUDE.md regardless of category. " +
48
- "Use for memories containing project-wide rules, conventions, or decisions that should be visible in CLAUDE.md. " +
47
+ "Compatibility alias: when true, sync this memory to the project's host instruction files (CLAUDE.md and/or AGENTS.md) regardless of category. " +
48
+ "Use for memories containing project-wide rules, conventions, or decisions that should be visible to coding agents. " +
49
49
  "Convention memories (type: preference) are always synced automatically.",
50
50
  ),
51
51
  },
@@ -82,17 +82,17 @@ export function registerStore(
82
82
 
83
83
  const memory = await backend.store(input);
84
84
 
85
- // Sync to CLAUDE.md: auto for conventions, opt-in for other categories
85
+ // Sync host instruction files: auto for conventions, opt-in for others.
86
86
  let claudeMdUpdated = false;
87
87
  const shouldSync =
88
88
  (memory.category === "conventions" || sync_to_claude_md) &&
89
89
  ctx?.docsDir;
90
90
  if (shouldSync) {
91
91
  try {
92
- syncToClaudeMd(ctx.docsDir, memory.id, description);
93
- claudeMdUpdated = true;
92
+ claudeMdUpdated =
93
+ syncToClaudeMd(ctx.docsDir, memory.id, description).length > 0;
94
94
  } catch {
95
- // Best-effort — don't block store on CLAUDE.md sync errors
95
+ // Best-effort — don't block store on instruction sync errors.
96
96
  }
97
97
  }
98
98
 
@@ -3,7 +3,7 @@ import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
3
3
  import { z } from "zod";
4
4
  import type { MemoryBackend } from "../lib/backend.js";
5
5
  import { buildUpdateStatus } from "../lib/status-frame.js";
6
- import { updateInClaudeMd, syncToClaudeMd } from "../lib/claude-md.js";
6
+ import { syncToClaudeMd } from "../lib/claude-md.js";
7
7
  import type { ToolRegistrationContext } from "../server.js";
8
8
 
9
9
  export function registerUpdate(
@@ -33,7 +33,7 @@ export function registerUpdate(
33
33
  .boolean()
34
34
  .optional()
35
35
  .describe(
36
- "When true, sync this memory to the project's CLAUDE.md regardless of category. " +
36
+ "Compatibility alias: when true, sync this memory to the project's host instruction files (CLAUDE.md and/or AGENTS.md) regardless of category. " +
37
37
  "Convention memories (type: preference) are always synced automatically.",
38
38
  ),
39
39
  },
@@ -66,25 +66,19 @@ export function registerUpdate(
66
66
  };
67
67
  }
68
68
 
69
- // Sync to CLAUDE.md: auto for conventions, opt-in for other categories
69
+ // Sync host instruction files: auto for conventions, opt-in for others.
70
70
  let claudeMdUpdated = false;
71
71
  const shouldSync =
72
72
  (memory.category === "conventions" || sync_to_claude_md) &&
73
73
  ctx?.docsDir;
74
74
  if (shouldSync) {
75
75
  try {
76
- if (description) {
77
- // Description changed — update the CLAUDE.md entry
78
- updateInClaudeMd(ctx.docsDir, memory.id, description);
79
- } else {
80
- // Ensure entry exists (e.g. if memory was created before this feature)
76
+ claudeMdUpdated =
81
77
  syncToClaudeMd(
82
78
  ctx.docsDir,
83
79
  memory.id,
84
80
  memory.frontmatter.description,
85
- );
86
- }
87
- claudeMdUpdated = true;
81
+ ).length > 0;
88
82
  } catch {
89
83
  // Best-effort
90
84
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "coding-friend-cli",
3
- "version": "1.36.4",
3
+ "version": "1.38.0",
4
4
  "description": "CLI for coding-friend — host learning docs, setup MCP server, initialize projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,7 +10,8 @@
10
10
  "scripts": {
11
11
  "build": "tsup src/index.ts src/postinstall.ts --format esm --dts --clean",
12
12
  "postinstall": "node -e \"import('./dist/postinstall.js').catch(()=>{})\"",
13
- "prepublishOnly": "npm run build",
13
+ "prepublishOnly": "npm run build && npm run check:package",
14
+ "check:package": "node scripts/check-package.mjs",
14
15
  "dev": "tsx src/index.ts",
15
16
  "watch": "tsup src/index.ts src/postinstall.ts --format esm --dts --watch",
16
17
  "test": "vitest run && vitest run --config vitest.hooks.config.ts",
@@ -20,14 +21,41 @@
20
21
  },
21
22
  "files": [
22
23
  "dist",
23
- "lib"
24
+ "lib/cf-memory/package.json",
25
+ "lib/cf-memory/package-lock.json",
26
+ "lib/cf-memory/scripts",
27
+ "lib/cf-memory/src/backends",
28
+ "lib/cf-memory/src/bin",
29
+ "lib/cf-memory/src/daemon",
30
+ "lib/cf-memory/src/index.ts",
31
+ "lib/cf-memory/src/lib",
32
+ "lib/cf-memory/src/resources",
33
+ "lib/cf-memory/src/server.ts",
34
+ "lib/cf-memory/src/tools",
35
+ "lib/cf-memory/tsconfig.json",
36
+ "lib/learn-host/next.config.ts",
37
+ "lib/learn-host/package.json",
38
+ "lib/learn-host/package-lock.json",
39
+ "lib/learn-host/postcss.config.mjs",
40
+ "lib/learn-host/public/logo.svg",
41
+ "lib/learn-host/src",
42
+ "lib/learn-host/tsconfig.json",
43
+ "lib/learn-mcp/package.json",
44
+ "lib/learn-mcp/package-lock.json",
45
+ "lib/learn-mcp/src/bin",
46
+ "lib/learn-mcp/src/index.ts",
47
+ "lib/learn-mcp/src/lib",
48
+ "lib/learn-mcp/src/server.ts",
49
+ "lib/learn-mcp/src/tools",
50
+ "lib/learn-mcp/tsconfig.json"
24
51
  ],
25
52
  "keywords": [
26
53
  "coding-friend",
27
54
  "cli",
28
55
  "learning",
29
56
  "mcp",
30
- "claude"
57
+ "claude",
58
+ "codex"
31
59
  ],
32
60
  "author": {
33
61
  "name": "Anh-Thi Dinh",
@@ -1,317 +0,0 @@
1
- # CF Memory
2
-
3
- Persistent memory system for [Coding Friend](https://cf.dinhanhthi.com/). Provides MCP (Model Context Protocol) tools for storing, searching, and retrieving project knowledge across sessions.
4
-
5
- ## Architecture
6
-
7
- CF Memory uses a **3-tier graceful degradation** design — it automatically detects and uses the best available backend:
8
-
9
- | Tier | Backend | Features | When |
10
- | --------------------- | -------------------------- | ------------------------------------------------------------------------------ | --------------------------- |
11
- | **Tier 1** (Full) | SQLite + FTS5 + sqlite-vec | Hybrid search (BM25 keyword + semantic embeddings), RRF fusion, temporal decay | SQLite deps installed |
12
- | **Tier 2** (Lite) | MiniSearch daemon | In-memory BM25 + fuzzy search, file watcher, Unix Domain Socket | Daemon running |
13
- | **Tier 3** (Markdown) | Markdown file I/O | Substring matching, no external deps | Always available (fallback) |
14
-
15
- Detection: Tier 1 → Tier 2 → Tier 3 (first available wins).
16
-
17
- ## MCP Interface
18
-
19
- **6 tools:**
20
-
21
- | Tool | Description |
22
- | ----------------- | --------------------------------------------------------------- |
23
- | `memory_store` | Store a new memory with title, description, type, tags, content |
24
- | `memory_search` | Search memories by query with optional type/tags filter |
25
- | `memory_retrieve` | Fetch a specific memory by ID |
26
- | `memory_list` | List memories with optional type/category filter |
27
- | `memory_update` | Update fields of an existing memory |
28
- | `memory_delete` | Delete a memory by ID |
29
-
30
- **2 resources:**
31
-
32
- | Resource | Description |
33
- | ---------------- | ------------------------------------------------ |
34
- | `memory://index` | Browse all stored memories (JSON) |
35
- | `memory://stats` | Storage statistics (total, by category, by type) |
36
-
37
- ## Memory Model
38
-
39
- **Types** map to storage categories:
40
-
41
- | Type | Category (folder) | Use case |
42
- | ------------ | ----------------- | ------------------------------- |
43
- | `fact` | `features/` | Feature descriptions, facts |
44
- | `preference` | `conventions/` | Conventions, preferences |
45
- | `context` | `decisions/` | Architecture decisions, context |
46
- | `episode` | `bugs/` | Bug reports, debugging sessions |
47
- | `procedure` | `infrastructure/` | Procedures, infra setup |
48
-
49
- Memories are stored as Markdown files with YAML frontmatter in `docs/memory/<category>/`.
50
-
51
- Convention memories (`preference` type → `conventions/` folder) are automatically synced to the project's `CLAUDE.md` under a `## CF Memory: Project Rules` section. Other memory types can opt-in to CLAUDE.md sync by setting `sync_to_claude_md: true` when storing or updating — useful for decisions, infrastructure rules, or any project-wide rules that future sessions must follow. Entries are tracked via HTML comments (`<!-- cf:<id> -->`) and are automatically added, updated, or removed when the corresponding memory is stored, updated, or deleted.
52
-
53
- ## Embedding Models
54
-
55
- Tier 1 (SQLite) uses embedding models to generate vectors for semantic search. Two providers are supported:
56
-
57
- ### Providers
58
-
59
- | Provider | How it works | Default model | Pros | Cons |
60
- | ------------------- | ----------------------------------------------- | -------------------------------- | -------------------------------------------- | ------------------------------------------------ |
61
- | **Transformers.js** | Runs in-process via `@huggingface/transformers` | `Xenova/all-MiniLM-L6-v2` (384d) | Zero config, no external service | Slower first load (~5s), limited model selection |
62
- | **Ollama** | Calls local Ollama server API | `all-minilm:l6-v2` (384d) | Fast, wide model selection, GPU acceleration | Requires Ollama running separately |
63
-
64
- ### Recommended Models
65
-
66
- | Model | Dims | Size | Notes |
67
- | -------------------------- | ---- | ------- | --------------------------------------------------------------------- |
68
- | `all-minilm:l6-v2` | 384 | ~23 MB | **Default** — fast, good for small-to-medium collections |
69
- | `nomic-embed-text` | 768 | ~274 MB | **Recommended upgrade** — significantly better semantic understanding |
70
- | `mxbai-embed-large` | 1024 | ~670 MB | Best quality, suitable for large collections (100+ memories) |
71
- | `snowflake-arctic-embed:s` | 384 | ~67 MB | Alternative compact model |
72
- | `snowflake-arctic-embed:m` | 768 | ~250 MB | Good balance of quality and speed |
73
- | `bge-base-en-v1.5` | 768 | ~130 MB | Strong English-language model |
74
- | `bge-large-en-v1.5` | 1024 | ~670 MB | Top-tier English model |
75
-
76
- ### Using Ollama for Embeddings
77
-
78
- 1. Install Ollama: https://ollama.com/download
79
- 2. Pull a model:
80
- ```bash
81
- ollama pull nomic-embed-text
82
- ```
83
- 3. Configure in `.coding-friend/config.json`:
84
- ```json
85
- {
86
- "memory": {
87
- "embedding": {
88
- "provider": "ollama",
89
- "model": "nomic-embed-text"
90
- }
91
- }
92
- }
93
- ```
94
- 4. If you have existing memories, rebuild to re-embed:
95
- ```bash
96
- cf memory rebuild
97
- ```
98
-
99
- If Ollama is not running or the configured model is missing, the system falls back to Transformers.js automatically.
100
-
101
- ### Changing Models
102
-
103
- When you switch to a model with different dimensions (e.g., 384 → 768):
104
-
105
- 1. The system detects the mismatch on startup
106
- 2. Vector search is **disabled** with a warning
107
- 3. Run `cf memory rebuild` to re-embed all memories
108
- 4. Vector search is re-enabled with the new dimensions
109
-
110
- Markdown files are unaffected — they remain the source of truth.
111
-
112
- ### Dynamic Dimensions
113
-
114
- CF Memory includes a lookup table of known models and their dimensions. For models not in the table, it defaults to 384 dimensions. If you use an exotic model, the system logs a warning suggesting you verify dimensions.
115
-
116
- Known models include: all-MiniLM-L6-v2 (384d), nomic-embed-text (768d), mxbai-embed-large (1024d), snowflake-arctic-embed variants, and BGE variants.
117
-
118
- ## Project Structure
119
-
120
- ```
121
- src/
122
- ├── index.ts # MCP server entry (stdio transport)
123
- ├── server.ts # Tool registration
124
- ├── bin/
125
- │ └── cf-memory.ts # CLI entry point
126
- ├── tools/ # MCP tool handlers
127
- │ ├── store.ts
128
- │ ├── search.ts
129
- │ ├── retrieve.ts
130
- │ ├── list.ts
131
- │ ├── update.ts
132
- │ └── delete.ts
133
- ├── resources/
134
- │ └── index.ts # memory://index + memory://stats
135
- ├── backends/
136
- │ ├── markdown.ts # Tier 3: file-based backend
137
- │ ├── minisearch.ts # Tier 2: in-memory search backend
138
- │ └── sqlite/
139
- │ ├── index.ts # Tier 1: SQLite backend
140
- │ ├── schema.ts # DB schema + PRAGMAs
141
- │ ├── migrations.ts # Version tracking, vec table
142
- │ ├── search.ts # FTS5 + vector + RRF hybrid search
143
- │ └── embeddings.ts # Ollama / Transformers.js pipeline
144
- ├── daemon/
145
- │ ├── entry.ts # Daemon process entry
146
- │ ├── process.ts # Start/stop, PID management
147
- │ ├── server.ts # Hono HTTP app (UDS)
148
- │ └── watcher.ts # File watcher + index rebuild
149
- ├── lib/
150
- │ ├── types.ts # MemoryType, Memory, SearchResult, etc.
151
- │ ├── backend.ts # MemoryBackend interface (8 methods)
152
- │ ├── tier.ts # detectTier() + createBackendForTier()
153
- │ ├── daemon-client.ts # HTTP client over Unix Domain Socket
154
- │ ├── lazy-install.ts # On-demand dep installer
155
- │ ├── dedup.ts # Jaccard similarity deduplication
156
- │ ├── temporal-decay.ts # Recency + access scoring
157
- │ └── ollama.ts # Ollama detection + embedding provider
158
- └── __tests__/ # 14 test suites (vitest)
159
- ```
160
-
161
- ## Development
162
-
163
- ### Prerequisites
164
-
165
- - Node.js 22+
166
- - npm
167
-
168
- ### Setup
169
-
170
- ```bash
171
- cd cli/lib/cf-memory
172
- npm install
173
- ```
174
-
175
- ### Scripts
176
-
177
- | Command | Description |
178
- | -------------------- | ------------------------------------- |
179
- | `npm run build` | Compile TypeScript → `dist/` |
180
- | `npm run dev` | Run MCP server directly via tsx |
181
- | `npm run dev:watch` | Watch mode — recompile on changes |
182
- | `npm start` | Run compiled server (`dist/index.js`) |
183
- | `npm test` | Run all tests (vitest) |
184
- | `npm run test:watch` | Run tests in watch mode |
185
-
186
- ### Dev mode and `cf dev sync`
187
-
188
- CF Memory lives in `cli/lib/cf-memory/` (part of the CLI package), **not** in `plugin/`. This means `cf dev sync` is **not needed** — the CLI resolves cf-memory via `getLibPath()` which points directly to `cli/lib/cf-memory/dist/`.
189
-
190
- | Consumer | Needs `cf dev sync`? | How changes take effect |
191
- | ----------------------------------- | --------------------------------- | ---------------------------------------------------------------------------- |
192
- | CLI commands (`cf memory *`) | No | `dev:watch` recompiles `dist/` → picked up on next CLI invocation |
193
- | MCP server (if configured) | No | Needs MCP server **restart** (long-running process) |
194
- | Plugin skills (cf-fix, cf-ask, ...) | Yes (for skill file changes only) | Skills reference MCP tools by name — cf-memory code itself doesn't need sync |
195
-
196
- In short: run `npm run dev:watch` (or `npm run dev` from the monorepo root) and your changes are immediately available to CLI commands. If you're running the MCP server, restart it after changes.
197
-
198
- ### Running the MCP server locally
199
-
200
- ```bash
201
- # Via tsx (no build needed)
202
- npm run dev
203
-
204
- # Or build first, then run
205
- npm run build
206
- npm start
207
-
208
- # With custom docs directory
209
- MEMORY_DOCS_DIR=/path/to/docs/memory npm run dev
210
-
211
- # Force a specific tier
212
- MEMORY_TIER=markdown npm run dev # Options: auto | full | lite | markdown
213
- ```
214
-
215
- ### Running tests
216
-
217
- ```bash
218
- npm test # Run once
219
- npm run test:watch # Watch mode
220
- ```
221
-
222
- ### Working with the daemon (Tier 2)
223
-
224
- ```bash
225
- # Start daemon manually (for testing)
226
- node dist/daemon/entry.js ./docs/memory
227
-
228
- # With idle timeout (ms) and tier
229
- node dist/daemon/entry.js ./docs/memory 0 --tier=lite
230
- ```
231
-
232
- The daemon runs a Hono HTTP server on a Unix Domain Socket at `~/.coding-friend/memory/daemon.sock`, with PID tracking at `~/.coding-friend/memory/daemon.pid`.
233
-
234
- **Auto-reconnect with retry:** If the daemon dies (e.g., crash or explicit stop), the `DaemonClient` automatically respawns it on the next request with up to 3 retry attempts (1-second delay between retries). If all retries fail, it falls back to Tier 3 (markdown grep). This means mid-session daemon restarts are transparent — no manual intervention needed.
235
-
236
- ### Lazy dependencies (Tier 1)
237
-
238
- Heavy dependencies for Tier 1 (SQLite + embeddings) are installed on-demand into `~/.coding-friend/memory/node_modules/`, not in this package's `node_modules/`. These include:
239
-
240
- - `better-sqlite3` — native SQLite driver
241
- - `sqlite-vec` — vector search extension
242
- - `@huggingface/transformers` — local embeddings (fallback when Ollama is unavailable)
243
-
244
- To install them manually: `cf memory init`
245
-
246
- ### Migration script
247
-
248
- For migrating existing `docs/memory/` files to the current frontmatter format:
249
-
250
- ```bash
251
- npx tsx scripts/migrate-frontmatter.ts [docsDir]
252
- ```
253
-
254
- ## Integration with the CLI
255
-
256
- ### MCP setup for end users
257
-
258
- Users don't need to manually configure the MCP server. `cf init` includes a "CF Memory MCP" step that asks to add `coding-friend-memory` to the project's `.mcp.json` automatically. If skipped during init, users can run `cf memory mcp` to get the config for manual setup.
259
-
260
- ### CLI commands
261
-
262
- The `cf` CLI exposes memory commands that use this package:
263
-
264
- | Command | Description |
265
- | -------------------------- | -------------------------------------------------------------------------------------------------------------------- |
266
- | `cf memory status` | Show current tier, daemon status, memory count |
267
- | `cf memory search <query>` | Search memories from the terminal |
268
- | `cf memory list` | List all stored memories |
269
- | `cf memory start-daemon` | Start the MiniSearch daemon (Tier 2) |
270
- | `cf memory stop-daemon` | Stop the daemon |
271
- | `cf memory rebuild` | Rebuild search index (Tier 1 direct or via daemon) |
272
- | `cf memory init` | Install Tier 1 deps + import existing memories into SQLite (see [prerequisites](#prerequisites-for-tier-1-on-linux)) |
273
- | `cf memory mcp` | Print MCP server config for use in Claude Desktop / other clients |
274
-
275
- ## Prerequisites for Tier 1 on Linux
276
-
277
- Tier 1 uses `better-sqlite3` and `sqlite-vec`, which are native Node.js modules requiring C++ compilation. On a fresh Linux install, you need build tools before running `cf memory init`:
278
-
279
- **Ubuntu/Debian:**
280
-
281
- ```bash
282
- sudo apt update
283
- sudo apt install -y build-essential python3
284
- ```
285
-
286
- **Fedora/RHEL:**
287
-
288
- ```bash
289
- sudo dnf groupinstall "Development Tools"
290
- sudo dnf install python3
291
- ```
292
-
293
- **Arch Linux:**
294
-
295
- ```bash
296
- sudo pacman -S base-devel python
297
- ```
298
-
299
- If these are missing, `cf memory init` will fail at the "Installing SQLite dependencies" step. You can still use Tier 2 (lite) or Tier 3 (markdown) without native dependencies — choose them during the init wizard.
300
-
301
- **macOS** users need Xcode Command Line Tools: `xcode-select --install`.
302
-
303
- ## Environment Variables
304
-
305
- | Variable | Default | Description |
306
- | ----------------------------- | ------------------------ | ------------------------------------------------- |
307
- | `MEMORY_DOCS_DIR` | `./docs/memory` | Path to memory storage directory |
308
- | `MEMORY_TIER` | `auto` | Force a tier: `auto`, `full`, `lite`, `markdown` |
309
- | `MEMORY_DAEMON_IDLE_TIMEOUT` | `0` (no timeout) | Daemon idle timeout in ms (`0` = never auto-stop) |
310
- | `MEMORY_EMBEDDING_PROVIDER` | `transformers` | Embedding provider: `transformers` or `ollama` |
311
- | `MEMORY_EMBEDDING_MODEL` | (provider default) | Embedding model name (e.g., `nomic-embed-text`) |
312
- | `MEMORY_EMBEDDING_OLLAMA_URL` | `http://localhost:11434` | Ollama server URL |
313
- | `OLLAMA_HOST` | `http://localhost:11434` | Ollama server URL (used by Ollama auto-detection) |
314
-
315
- ## Versioning
316
-
317
- Part of the [coding-friend](https://github.com/dinhanhthi/coding-friend) monorepo. Versioned and released as part of the CLI package. Changelog: [`cli/CHANGELOG.md`](../../CHANGELOG.md).