linksee-memory 0.4.0 → 0.4.1

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 CHANGED
@@ -101,44 +101,43 @@ It is a Model Context Protocol (MCP) server that gives any AI agent four superpo
101
101
  2. **Cross-agent portability** — single SQLite file at `~/.linksee-memory/memory.db`. Same brain for Claude Code, Cursor, OpenAI Codex, Gemini CLI. (ChatGPT app needs Remote MCP — on roadmap for v0.4.)
102
102
  3. **WHY-first structured memory** — six explicit layers (`goal` / `context` / `emotion` / `implementation` / `caveat` / `learning`). Solves "flat fact memory is useless without goals".
103
103
 
104
- ## Install
104
+ ## Quick Start — One Command
105
105
 
106
106
  ```bash
107
- npm install -g linksee-memory
108
- linksee-memory-import --help # bundled importer for Claude Code session history
107
+ npx linksee-memory-setup
109
108
  ```
110
109
 
111
- Or use `npx` ad hoc:
110
+ This does everything:
111
+ 1. Registers the MCP server with Claude Code
112
+ 2. Installs the agent skill (teaches the agent when to recall/remember)
113
+ 3. Configures auto-capture (every session saved to your local brain)
112
114
 
113
- ```bash
114
- npx linksee-memory # starts the MCP server on stdio
115
- ```
115
+ Restart Claude Code, then just chat normally. Add **"Use Linksee"** to any prompt to trigger memory recall.
116
116
 
117
- The default database lives at `~/.linksee-memory/memory.db`. Override with the `LINKSEE_MEMORY_DIR` environment variable.
117
+ ### Manual setup (if you prefer step-by-step)
118
118
 
119
- ## Register with Claude Code
119
+ <details>
120
+ <summary>Click to expand manual installation</summary>
121
+
122
+ **Install & register:**
120
123
 
121
124
  ```bash
122
125
  claude mcp add -s user linksee -- npx -y linksee-memory
123
126
  ```
124
127
 
125
- Restart Claude Code. Tools appear as `mcp__linksee__remember`, `mcp__linksee__recall`, `mcp__linksee__recall_file`, `mcp__linksee__read_smart`, `mcp__linksee__forget`, `mcp__linksee__consolidate`.
126
-
127
- ### Recommended: install the skill (auto-invocation)
128
+ Tools appear as `mcp__linksee__remember`, `mcp__linksee__recall`, `mcp__linksee__recall_file`, `mcp__linksee__read_smart`, `mcp__linksee__forget`, `mcp__linksee__consolidate`.
128
129
 
129
- Installing the MCP alone doesn't teach Claude Code *when* to call `recall` / `remember`. The bundled skill fixes that:
130
+ **Install the skill (auto-invocation):**
130
131
 
131
132
  ```bash
132
133
  npx -y linksee-memory-install-skill
133
134
  ```
134
135
 
135
- This copies a `SKILL.md` to `~/.claude/skills/linksee-memory/`. Claude Code auto-discovers it and fires the skill on phrases like "前に…", "また同じエラー", "覚えておいて", new task starts, file edits, and so on — no need to say "use linksee-memory".
136
+ Copies `SKILL.md` to `~/.claude/skills/linksee-memory/`. Agent auto-fires on phrases like "前に…", "また同じエラー", "覚えておいて", new task starts, file edits, etc.
136
137
 
137
- Flags: `--dry-run`, `--force`, `--help`.
138
+ **Configure auto-capture (Stop hook):**
138
139
 
139
- ### Optional: auto-capture every session (Stop hook)
140
-
141
- Add to `~/.claude/settings.json` to record every Claude Code session to your local brain automatically:
140
+ Add to `~/.claude/settings.json`:
142
141
 
143
142
  ```json
144
143
  {
@@ -155,7 +154,13 @@ Add to `~/.claude/settings.json` to record every Claude Code session to your loc
155
154
  }
156
155
  ```
157
156
 
158
- Each turn end takes ~100 ms. Failures are silent (Claude Code never blocks). Logs at `~/.linksee-memory/hook.log`.
157
+ Each turn end takes ~100 ms. Failures are silent. Logs at `~/.linksee-memory/hook.log`.
158
+
159
+ </details>
160
+
161
+ ### Database location
162
+
163
+ Default: `~/.linksee-memory/memory.db`. Override with `LINKSEE_MEMORY_DIR` env var.
159
164
 
160
165
  ## v0.3.0 — Five Blocks at a glance
161
166
 
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,220 @@
1
+ #!/usr/bin/env node
2
+ // setup: One-command setup for Linksee Memory — the "Use Linksee" installer.
3
+ //
4
+ // Usage:
5
+ // npx linksee-memory-setup (interactive setup)
6
+ // npx linksee-memory-setup --yes (accept all defaults, no prompts)
7
+ // npx linksee-memory-setup --dry-run
8
+ //
9
+ // Does three things:
10
+ // 1. Registers the MCP server with Claude Code
11
+ // 2. Installs the SKILL.md (agent trigger phrases)
12
+ // 3. Configures the Stop hook (auto-capture sessions)
13
+ //
14
+ // After setup, every Claude Code session:
15
+ // - Auto-captures decisions, learnings, caveats to local memory
16
+ // - Agent auto-recalls past context at task start (via SKILL.md triggers)
17
+ // - "Use Linksee" in any prompt forces a recall
18
+ //
19
+ // Why: Competing memory tools (claude-mem, etc.) are one-install-and-done.
20
+ // Our MCP approach gives more precision, but the setup was 3 manual steps.
21
+ // This command eliminates that friction entirely.
22
+ import { spawnSync } from 'node:child_process';
23
+ import { existsSync, readFileSync, writeFileSync, mkdirSync, copyFileSync } from 'node:fs';
24
+ import { join, dirname } from 'node:path';
25
+ import { homedir } from 'node:os';
26
+ import { fileURLToPath } from 'node:url';
27
+ const args = process.argv.slice(2);
28
+ const dryRun = args.includes('--dry-run');
29
+ const autoYes = args.includes('--yes') || args.includes('-y');
30
+ const showHelp = args.includes('--help') || args.includes('-h');
31
+ if (showHelp) {
32
+ console.log(`linksee-memory-setup — One-command setup for Linksee Memory
33
+
34
+ Usage:
35
+ npx linksee-memory-setup Interactive setup
36
+ npx linksee-memory-setup --yes Accept all defaults, no prompts
37
+ npx linksee-memory-setup --dry-run Show what would happen
38
+
39
+ What it does:
40
+ 1. Registers linksee-memory MCP server with Claude Code
41
+ 2. Installs SKILL.md (teaches the agent when to recall/remember)
42
+ 3. Configures Stop hook (auto-captures every session)
43
+
44
+ After setup, just chat with Claude Code normally.
45
+ Add "Use Linksee" to any prompt to trigger memory recall.`);
46
+ process.exit(0);
47
+ }
48
+ // ── Constants ────────────────────────────────────────────
49
+ const HOME = homedir();
50
+ const CLAUDE_DIR = join(HOME, '.claude');
51
+ const SETTINGS_PATH = join(CLAUDE_DIR, 'settings.json');
52
+ const SKILL_DIR = join(CLAUDE_DIR, 'skills', 'linksee-memory');
53
+ const SKILL_TARGET = join(SKILL_DIR, 'SKILL.md');
54
+ const __filename = fileURLToPath(import.meta.url);
55
+ const SKILL_SRC = join(dirname(__filename), '..', 'skill', 'SKILL.md');
56
+ const SERVER_NAME = 'linksee';
57
+ const MCP_COMMAND = `claude mcp add -s user ${SERVER_NAME} -- npx -y linksee-memory`;
58
+ const HOOK_COMMAND = 'npx -y linksee-memory-sync';
59
+ const CHECK = '\x1b[32m✓\x1b[0m';
60
+ const SKIP = '\x1b[33m○\x1b[0m';
61
+ const FAIL = '\x1b[31m✗\x1b[0m';
62
+ const BOLD = '\x1b[1m';
63
+ const DIM = '\x1b[2m';
64
+ const RESET = '\x1b[0m';
65
+ console.log('');
66
+ console.log(`${BOLD}Linksee Memory Setup${RESET}`);
67
+ console.log(`${DIM}Local-first cross-LLM memory · precision recall${RESET}`);
68
+ console.log('');
69
+ // ── Step 1: Register MCP server ──────────────────────────
70
+ console.log(`${BOLD}[1/3]${RESET} Registering MCP server...`);
71
+ let mcpAlreadyRegistered = false;
72
+ try {
73
+ // Check if already registered by looking at settings.json or .claude.json
74
+ for (const confFile of [SETTINGS_PATH, join(HOME, '.claude.json')]) {
75
+ if (!existsSync(confFile))
76
+ continue;
77
+ try {
78
+ const conf = JSON.parse(readFileSync(confFile, 'utf8'));
79
+ if (conf?.mcpServers?.[SERVER_NAME]) {
80
+ mcpAlreadyRegistered = true;
81
+ break;
82
+ }
83
+ }
84
+ catch { /* ignore parse errors */ }
85
+ }
86
+ }
87
+ catch { /* ignore */ }
88
+ if (mcpAlreadyRegistered) {
89
+ console.log(` ${SKIP} MCP server '${SERVER_NAME}' already registered`);
90
+ }
91
+ else if (dryRun) {
92
+ console.log(` ${DIM}[dry-run] Would run: ${MCP_COMMAND}${RESET}`);
93
+ }
94
+ else {
95
+ try {
96
+ // Check if 'claude' CLI is available
97
+ const which = spawnSync(process.platform === 'win32' ? 'where' : 'which', ['claude'], {
98
+ encoding: 'utf8',
99
+ timeout: 5000,
100
+ });
101
+ if (which.status !== 0) {
102
+ console.log(` ${FAIL} 'claude' CLI not found. Install Claude Code first:`);
103
+ console.log(` https://docs.anthropic.com/en/docs/claude-code`);
104
+ console.log(` ${DIM}Then run this setup again.${RESET}`);
105
+ }
106
+ else {
107
+ const r = spawnSync('claude', ['mcp', 'add', '-s', 'user', SERVER_NAME, '--', 'npx', '-y', 'linksee-memory'], {
108
+ encoding: 'utf8',
109
+ timeout: 15000,
110
+ stdio: ['pipe', 'pipe', 'pipe'],
111
+ });
112
+ if (r.status === 0) {
113
+ console.log(` ${CHECK} MCP server registered as '${SERVER_NAME}'`);
114
+ }
115
+ else {
116
+ // May fail if already exists with different config
117
+ const stderr = (r.stderr || '').trim();
118
+ if (stderr.includes('already exists') || stderr.includes('already registered')) {
119
+ console.log(` ${SKIP} MCP server '${SERVER_NAME}' already registered`);
120
+ }
121
+ else {
122
+ console.log(` ${FAIL} Registration failed: ${stderr || 'unknown error'}`);
123
+ console.log(` ${DIM}Manual: ${MCP_COMMAND}${RESET}`);
124
+ }
125
+ }
126
+ }
127
+ }
128
+ catch (e) {
129
+ console.log(` ${FAIL} Error: ${e?.message ?? e}`);
130
+ console.log(` ${DIM}Manual: ${MCP_COMMAND}${RESET}`);
131
+ }
132
+ }
133
+ console.log('');
134
+ // ── Step 2: Install SKILL.md ─────────────────────────────
135
+ console.log(`${BOLD}[2/3]${RESET} Installing agent skill...`);
136
+ if (!existsSync(SKILL_SRC)) {
137
+ console.log(` ${FAIL} Bundled SKILL.md not found (packaging bug)`);
138
+ console.log(` ${DIM}Expected at: ${SKILL_SRC}${RESET}`);
139
+ }
140
+ else if (dryRun) {
141
+ console.log(` ${DIM}[dry-run] Would copy to: ${SKILL_TARGET}${RESET}`);
142
+ }
143
+ else {
144
+ mkdirSync(SKILL_DIR, { recursive: true });
145
+ let shouldWrite = true;
146
+ if (existsSync(SKILL_TARGET)) {
147
+ try {
148
+ const existing = readFileSync(SKILL_TARGET, 'utf8');
149
+ const bundled = readFileSync(SKILL_SRC, 'utf8');
150
+ if (existing === bundled) {
151
+ console.log(` ${SKIP} Skill already installed and up to date`);
152
+ shouldWrite = false;
153
+ }
154
+ else {
155
+ // Newer version — overwrite
156
+ console.log(` ${DIM}Updating to latest version...${RESET}`);
157
+ }
158
+ }
159
+ catch { /* fallthrough to write */ }
160
+ }
161
+ if (shouldWrite) {
162
+ copyFileSync(SKILL_SRC, SKILL_TARGET);
163
+ console.log(` ${CHECK} Skill installed → ${SKILL_TARGET}`);
164
+ }
165
+ }
166
+ console.log('');
167
+ // ── Step 3: Configure Stop hook ──────────────────────────
168
+ console.log(`${BOLD}[3/3]${RESET} Configuring auto-capture hook...`);
169
+ let settings = {};
170
+ if (existsSync(SETTINGS_PATH)) {
171
+ try {
172
+ settings = JSON.parse(readFileSync(SETTINGS_PATH, 'utf8'));
173
+ }
174
+ catch {
175
+ console.log(` ${FAIL} Could not parse ${SETTINGS_PATH}`);
176
+ settings = {};
177
+ }
178
+ }
179
+ // Check if hook already exists
180
+ const stopHooks = settings?.hooks?.Stop ?? [];
181
+ const alreadyHooked = stopHooks.some((entry) => entry.hooks?.some((h) => h.command?.includes('linksee-memory-sync')));
182
+ if (alreadyHooked) {
183
+ console.log(` ${SKIP} Stop hook already configured`);
184
+ }
185
+ else if (dryRun) {
186
+ console.log(` ${DIM}[dry-run] Would add Stop hook to ${SETTINGS_PATH}${RESET}`);
187
+ }
188
+ else {
189
+ // Add hook
190
+ if (!settings.hooks)
191
+ settings.hooks = {};
192
+ if (!settings.hooks.Stop)
193
+ settings.hooks.Stop = [];
194
+ settings.hooks.Stop.push({
195
+ matcher: '',
196
+ hooks: [{ type: 'command', command: HOOK_COMMAND }],
197
+ });
198
+ mkdirSync(CLAUDE_DIR, { recursive: true });
199
+ writeFileSync(SETTINGS_PATH, JSON.stringify(settings, null, 2), 'utf8');
200
+ console.log(` ${CHECK} Stop hook added → ${SETTINGS_PATH}`);
201
+ }
202
+ console.log('');
203
+ // ── Summary ──────────────────────────────────────────────
204
+ console.log(`${BOLD}Setup complete!${RESET}`);
205
+ console.log('');
206
+ console.log('How it works:');
207
+ console.log(` ${DIM}• Every session is auto-captured (decisions, caveats, learnings)${RESET}`);
208
+ console.log(` ${DIM}• Agent auto-recalls past context when starting a task${RESET}`);
209
+ console.log(` ${DIM}• Memory is local-first (nothing leaves your machine)${RESET}`);
210
+ console.log(` ${DIM}• Works across Claude Code, Cursor, ChatGPT (cross-LLM)${RESET}`);
211
+ console.log('');
212
+ console.log('Test by asking:');
213
+ console.log(` ${BOLD}"How did we solve this before?"${RESET}`);
214
+ console.log(` ${BOLD}"Same error again"${RESET}`);
215
+ console.log(` ${BOLD}"Remember: I prefer TypeScript over JavaScript"${RESET}`);
216
+ console.log(` ${BOLD}「前にこの問題どう解決したっけ」${RESET}`);
217
+ console.log('');
218
+ console.log(`Or add ${BOLD}"Use Linksee"${RESET} to any prompt to trigger memory recall.`);
219
+ console.log('');
220
+ //# sourceMappingURL=setup.js.map
@@ -14,8 +14,8 @@ description: |
14
14
  ⑥ When asked "why did we do that", "when was this decided", "where did we discuss this" / 「なぜそうした」「いつ決めた」「どこで議論した」
15
15
  ⑦ Returning from another project / switching sessions / 別プロジェクトから戻ってきたとき
16
16
 
17
- Triggers (EN): remember/recall/forget/memory/before/earlier/last time/previously/remember when/same as before/history
18
- Triggers (JP): 記憶/覚えて/忘れて/過去/前回/前に/そういえば/覚えてる
17
+ Triggers (EN): remember/recall/forget/memory/before/earlier/last time/previously/remember when/same as before/history/use linksee/linksee
18
+ Triggers (JP): 記憶/覚えて/忘れて/過去/前回/前に/そういえば/覚えてる/リンクシー
19
19
  Error keywords (EN): failed/broken/stuck/error/bug/doesn't work/not working/same error again/again/repeated/debug
20
20
  Error keywords (JP): 失敗/エラー/うまくいかない/ハマった/同じ/また/繰り返し
21
21
  Decision keywords (EN): decided/let's go with/approved/settled on/pivot/strategy/switch to/abandon
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "linksee-memory",
3
- "version": "0.4.0",
3
+ "version": "0.4.1",
4
4
  "mcpName": "io.github.michielinksee/linksee-memory",
5
5
  "description": "Local-first agent memory MCP — cross-agent brain with 6-layer structured memory + token-saving file diff cache",
6
6
  "type": "module",
@@ -9,7 +9,8 @@
9
9
  "linksee-memory-import": "dist/bin/import-sessions.js",
10
10
  "linksee-memory-sync": "dist/bin/sync-session.js",
11
11
  "linksee-memory-install-skill": "dist/bin/install-skill.js",
12
- "linksee-memory-stats": "dist/bin/stats.js"
12
+ "linksee-memory-stats": "dist/bin/stats.js",
13
+ "linksee-memory-setup": "dist/bin/setup.js"
13
14
  },
14
15
  "main": "./dist/mcp/server.js",
15
16
  "files": [