linksee-memory 0.0.6 → 0.0.8
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 +101 -0
- package/dist/bin/install-skill.d.ts +2 -0
- package/dist/bin/install-skill.js +93 -0
- package/dist/lib/session-extractor.js +12 -2
- package/dist/skill/SKILL.md +321 -0
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -48,6 +48,18 @@ claude mcp add -s user linksee -- npx -y linksee-memory
|
|
|
48
48
|
|
|
49
49
|
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`.
|
|
50
50
|
|
|
51
|
+
### Recommended: install the skill (auto-invocation)
|
|
52
|
+
|
|
53
|
+
Installing the MCP alone doesn't teach Claude Code *when* to call `recall` / `remember`. The bundled skill fixes that:
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
npx -y linksee-memory-install-skill
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
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".
|
|
60
|
+
|
|
61
|
+
Flags: `--dry-run`, `--force`, `--help`.
|
|
62
|
+
|
|
51
63
|
### Optional: auto-capture every session (Stop hook)
|
|
52
64
|
|
|
53
65
|
Add to `~/.claude/settings.json` to record every Claude Code session to your local brain automatically:
|
|
@@ -179,6 +191,95 @@ Aggregated MCP-usage data helps the [KanseiLink](https://kansei-link.com) projec
|
|
|
179
191
|
|
|
180
192
|
The full payload schema and validation logic is open-source — read `src/lib/telemetry.ts` if you want to verify exactly what leaves your machine.
|
|
181
193
|
|
|
194
|
+
## Pricing
|
|
195
|
+
|
|
196
|
+
**Free forever.**
|
|
197
|
+
|
|
198
|
+
linksee-memory is local-first and runs entirely on your machine. There is no hosted component you need to pay for. The SQLite DB lives in your home directory; backup = file copy.
|
|
199
|
+
|
|
200
|
+
No account, no credit card, no API key. Just install and use.
|
|
201
|
+
|
|
202
|
+
## Troubleshooting
|
|
203
|
+
|
|
204
|
+
<details>
|
|
205
|
+
<summary><b>The skill isn't firing — Claude Code doesn't call <code>recall</code> when I ask about past work.</b></summary>
|
|
206
|
+
|
|
207
|
+
1. Verify the skill was installed:
|
|
208
|
+
```bash
|
|
209
|
+
ls ~/.claude/skills/linksee-memory/SKILL.md
|
|
210
|
+
```
|
|
211
|
+
If absent, run `npx -y linksee-memory-install-skill`.
|
|
212
|
+
2. Restart Claude Code. Skills are indexed on session start.
|
|
213
|
+
3. Check that the MCP is registered under the name `linksee` (the skill expects `mcp__linksee__*` tool names):
|
|
214
|
+
```bash
|
|
215
|
+
claude mcp list | grep linksee
|
|
216
|
+
```
|
|
217
|
+
If it's registered as something else, either re-register or edit `~/.claude/skills/linksee-memory/SKILL.md` to match.
|
|
218
|
+
</details>
|
|
219
|
+
|
|
220
|
+
<details>
|
|
221
|
+
<summary><b>Stop hook isn't recording my sessions.</b></summary>
|
|
222
|
+
|
|
223
|
+
1. Check the hook log: `cat ~/.linksee-memory/hook.log`
|
|
224
|
+
2. Run a manual test:
|
|
225
|
+
```bash
|
|
226
|
+
echo '{"session_id":"test","transcript_path":"/path/to/some.jsonl"}' | npx linksee-memory-sync
|
|
227
|
+
```
|
|
228
|
+
3. Make sure the `Stop` hook in `~/.claude/settings.json` points to `npx -y linksee-memory-sync` (not the old `-import`).
|
|
229
|
+
</details>
|
|
230
|
+
|
|
231
|
+
<details>
|
|
232
|
+
<summary><b>Upgrading from v0.0.5 or earlier — my recalls are mostly tagged "Card_Navi" or my project-dir name.</b></summary>
|
|
233
|
+
|
|
234
|
+
v0.0.6+ fixed the entity detection bug that collapsed all memories into the session's starting cwd. To re-index existing history with correct project attribution, run:
|
|
235
|
+
|
|
236
|
+
```bash
|
|
237
|
+
npx linksee-memory-import --all
|
|
238
|
+
```
|
|
239
|
+
|
|
240
|
+
The importer is idempotent (wipes existing session data before re-inserting). Typical runtime: a few minutes for hundreds of sessions. Expect a dramatic improvement in `recall` precision afterward.
|
|
241
|
+
</details>
|
|
242
|
+
|
|
243
|
+
<details>
|
|
244
|
+
<summary><b><code>recall</code> returns too much — the context window fills up fast.</b></summary>
|
|
245
|
+
|
|
246
|
+
Reduce `max_tokens`:
|
|
247
|
+
```
|
|
248
|
+
recall({ query: "...", max_tokens: 800 }) // default is 2000
|
|
249
|
+
```
|
|
250
|
+
Or narrow with `entity_name` and `layer`:
|
|
251
|
+
```
|
|
252
|
+
recall({ query: "...", entity_name: "my-project", layer: "caveat" })
|
|
253
|
+
```
|
|
254
|
+
</details>
|
|
255
|
+
|
|
256
|
+
<details>
|
|
257
|
+
<summary><b>How do I reset / delete all memory?</b></summary>
|
|
258
|
+
|
|
259
|
+
```bash
|
|
260
|
+
rm -rf ~/.linksee-memory # nuke everything; next run creates a fresh DB
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
Or delete individual memories via the `forget` tool with a specific `memory_id`.
|
|
264
|
+
</details>
|
|
265
|
+
|
|
266
|
+
<details>
|
|
267
|
+
<summary><b>DB is getting large (>100 MB). How do I trim it?</b></summary>
|
|
268
|
+
|
|
269
|
+
Run consolidate — it clusters old cold memories into compressed learning-layer summaries:
|
|
270
|
+
```
|
|
271
|
+
consolidate({ scope: "all", min_age_days: 7 })
|
|
272
|
+
```
|
|
273
|
+
Caveat and active-goal layers are always preserved. Consider scheduling a weekly run via cron / Task Scheduler.
|
|
274
|
+
</details>
|
|
275
|
+
|
|
276
|
+
## Support
|
|
277
|
+
|
|
278
|
+
- **Issues & bug reports**: [github.com/michielinksee/linksee-memory/issues](https://github.com/michielinksee/linksee-memory/issues)
|
|
279
|
+
- **Feature requests**: open an issue with the `enhancement` label
|
|
280
|
+
- **Security concerns**: see [SECURITY.md](./SECURITY.md) if present, or file a private advisory on GitHub
|
|
281
|
+
- **Company**: Synapse Arrows PTE. LTD. (Singapore)
|
|
282
|
+
|
|
182
283
|
## License
|
|
183
284
|
|
|
184
285
|
MIT — Synapse Arrows PTE. LTD.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// install-skill: copies the bundled SKILL.md into ~/.claude/skills/linksee-memory/
|
|
3
|
+
// so Claude Code can auto-invoke linksee-memory based on user intent.
|
|
4
|
+
//
|
|
5
|
+
// Usage:
|
|
6
|
+
// npx linksee-memory-install-skill (safe — won't overwrite without --force)
|
|
7
|
+
// npx linksee-memory-install-skill --force (overwrite existing file)
|
|
8
|
+
// npx linksee-memory-install-skill --dry-run (show what would happen)
|
|
9
|
+
//
|
|
10
|
+
// Why: installing the MCP server alone doesn't teach Claude Code WHEN to call
|
|
11
|
+
// recall/remember/read_smart/etc. The skill provides trigger phrases ("前に...",
|
|
12
|
+
// "また同じエラー", new task start, file edits, etc.) so the agent auto-fires
|
|
13
|
+
// without the user having to type "use linksee-memory".
|
|
14
|
+
import { mkdirSync, existsSync, copyFileSync, readFileSync } from 'node:fs';
|
|
15
|
+
import { join, dirname } from 'node:path';
|
|
16
|
+
import { homedir } from 'node:os';
|
|
17
|
+
import { fileURLToPath } from 'node:url';
|
|
18
|
+
const args = process.argv.slice(2);
|
|
19
|
+
const force = args.includes('--force') || args.includes('-f');
|
|
20
|
+
const dryRun = args.includes('--dry-run');
|
|
21
|
+
const showHelp = args.includes('--help') || args.includes('-h');
|
|
22
|
+
if (showHelp) {
|
|
23
|
+
console.log(`linksee-memory-install-skill
|
|
24
|
+
|
|
25
|
+
Install the linksee-memory Claude Code skill into ~/.claude/skills/linksee-memory/.
|
|
26
|
+
|
|
27
|
+
Options:
|
|
28
|
+
--force, -f Overwrite an existing skill file
|
|
29
|
+
--dry-run Show what would happen without writing
|
|
30
|
+
--help, -h This message
|
|
31
|
+
|
|
32
|
+
After installation, ensure the MCP server is registered in Claude Code:
|
|
33
|
+
claude mcp add -s user linksee -- npx -y linksee-memory
|
|
34
|
+
|
|
35
|
+
The skill expects tool names of the form mcp__linksee__*. If you register the
|
|
36
|
+
server under a different name (e.g. "linksee-memory"), edit the skill file
|
|
37
|
+
afterwards.`);
|
|
38
|
+
process.exit(0);
|
|
39
|
+
}
|
|
40
|
+
// The bundled skill lives next to us in dist/skill/ after build
|
|
41
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
42
|
+
const skillSrc = join(dirname(__filename), '..', 'skill', 'SKILL.md');
|
|
43
|
+
if (!existsSync(skillSrc)) {
|
|
44
|
+
console.error(`[error] bundled skill not found at ${skillSrc}`);
|
|
45
|
+
console.error('This is a packaging bug. Please file an issue at:');
|
|
46
|
+
console.error(' https://github.com/michielinksee/linksee-memory/issues');
|
|
47
|
+
process.exit(1);
|
|
48
|
+
}
|
|
49
|
+
const targetDir = join(homedir(), '.claude', 'skills', 'linksee-memory');
|
|
50
|
+
const targetFile = join(targetDir, 'SKILL.md');
|
|
51
|
+
const exists = existsSync(targetFile);
|
|
52
|
+
if (dryRun) {
|
|
53
|
+
console.log('[dry-run] Would install skill:');
|
|
54
|
+
console.log(` source: ${skillSrc}`);
|
|
55
|
+
console.log(` target: ${targetFile}`);
|
|
56
|
+
console.log(` exists: ${exists ? 'yes (would NOT overwrite without --force)' : 'no'}`);
|
|
57
|
+
process.exit(0);
|
|
58
|
+
}
|
|
59
|
+
mkdirSync(targetDir, { recursive: true });
|
|
60
|
+
if (exists && !force) {
|
|
61
|
+
try {
|
|
62
|
+
const bundled = readFileSync(skillSrc, 'utf8');
|
|
63
|
+
const installed = readFileSync(targetFile, 'utf8');
|
|
64
|
+
if (bundled === installed) {
|
|
65
|
+
console.log(`[ok] Skill already installed and up to date:`);
|
|
66
|
+
console.log(` ${targetFile}`);
|
|
67
|
+
process.exit(0);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
catch {
|
|
71
|
+
/* fall through */
|
|
72
|
+
}
|
|
73
|
+
console.log(`[skip] A skill already exists at ${targetFile}`);
|
|
74
|
+
console.log(' The bundled version differs. To overwrite, run:');
|
|
75
|
+
console.log(' linksee-memory-install-skill --force');
|
|
76
|
+
process.exit(0);
|
|
77
|
+
}
|
|
78
|
+
copyFileSync(skillSrc, targetFile);
|
|
79
|
+
console.log(`[ok] Skill installed: ${targetFile}`);
|
|
80
|
+
console.log('');
|
|
81
|
+
console.log('Next steps:');
|
|
82
|
+
console.log(' 1. Ensure the linksee-memory MCP server is registered:');
|
|
83
|
+
console.log(' claude mcp add -s user linksee -- npx -y linksee-memory');
|
|
84
|
+
console.log('');
|
|
85
|
+
console.log(' 2. Restart Claude Code (the skill auto-loads on next turn).');
|
|
86
|
+
console.log('');
|
|
87
|
+
console.log(' 3. Test by saying something like:');
|
|
88
|
+
console.log(' "前にこの問題どう解決したっけ"');
|
|
89
|
+
console.log(' "また同じエラーが出た"');
|
|
90
|
+
console.log(' "覚えておいて: ..."');
|
|
91
|
+
console.log('');
|
|
92
|
+
console.log('The skill will trigger and call recall/remember automatically.');
|
|
93
|
+
//# sourceMappingURL=install-skill.js.map
|
|
@@ -31,9 +31,19 @@ const FAILURE_PATTERNS = [
|
|
|
31
31
|
/失敗|バグ|エラー|直して|修正|戻して/,
|
|
32
32
|
/error|bug|fail|broken|revert|rollback/i,
|
|
33
33
|
];
|
|
34
|
+
// Caveats must be EXPLICIT warnings/prohibitions the user wants preserved.
|
|
35
|
+
// Previous bare patterns (/注意/ /やらない/ /避けて/) caught descriptive usage
|
|
36
|
+
// like「一般ユーザーはやらない」「Anthropicがやらない範囲」and turned
|
|
37
|
+
// opinions into protected caveats. Tightened to imperative/prohibitive forms
|
|
38
|
+
// only. Loses some recall, but precision matters more for the "never forget"
|
|
39
|
+
// layer.
|
|
34
40
|
const CAVEAT_PATTERNS = [
|
|
35
|
-
|
|
36
|
-
/
|
|
41
|
+
// Imperative negations: any verb-stem + ないで is a command "don't X".
|
|
42
|
+
// The 「[ぁ-ん一-龯]ないで」 clause catches 触らないで / 消さないで / 使わないで /
|
|
43
|
+
// 書かないで etc. while `(?!いる|いない|ほし)` excludes descriptive forms
|
|
44
|
+
// like 「やらないでいる」 or 「やらないでほしい」 (state / request).
|
|
45
|
+
/気をつけて|注意して|[!!]注意[!!]|避けて(?!いる|いない)|[ぁ-ん一-龯]ないで(?!いる|いない|ほし)|やめて(?!おく|ほし)|禁止|ダメだ|危険/,
|
|
46
|
+
/\b(?:don'?t|do\s+not)\s+(?:do|use|run|call|forget|try|send|share|commit|push|paste|edit)\b|\bnever\s+(?:do|use|call|share|commit|paste|run|push|edit)\b|\bavoid(?:ing)?\b|\bwatch\s+out\b/i,
|
|
37
47
|
];
|
|
38
48
|
function matchesAny(text, patterns) {
|
|
39
49
|
return patterns.some((p) => p.test(text));
|
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: linksee-memory
|
|
3
|
+
description: |
|
|
4
|
+
エージェントの「過去の自分」への橋。新しい作業・ファイル編集・意思決定・失敗の前後で、linksee-memory から過去の caveat(痛みの記録)/ learning(成長ログ)/ implementation(成功失敗)を recall する。
|
|
5
|
+
これは Claude Code の「毎セッション記憶喪失」問題を解決する唯一の方法。Mem0/Letta/Zep にはできない「同じ失敗を二度としない」仕組み。
|
|
6
|
+
以下のタイミングで必ずこのスキルを使うこと:
|
|
7
|
+
①作業開始時・新タスク開始時(「実装しよう」「始めよう」「新しく〜作る」)
|
|
8
|
+
②ファイル編集する前(同じファイルを過去に触ってる可能性がある)
|
|
9
|
+
③エラー・失敗した瞬間(remember で caveat 記録)
|
|
10
|
+
④成功した瞬間・新しいこと学んだ瞬間(remember で learning 記録)
|
|
11
|
+
⑤ユーザーが「前に」「同じ」「覚えてる?」「覚えておいて」と言ったとき
|
|
12
|
+
⑥「なぜそうした」「いつ決めた」「どこで議論した」と聞かれたとき
|
|
13
|
+
⑦別プロジェクトから戻ってきたとき・セッション切り替え時
|
|
14
|
+
トリガー: 記憶/覚えて/忘れて/過去/前回/前に/そういえば/覚えてる/memory/remember/recall/forget
|
|
15
|
+
エラーキーワード: 失敗/エラー/うまくいかない/ハマった/同じ/また/繰り返し/debug
|
|
16
|
+
決定キーワード: 決めた/方針/戦略/ピボット/やめよう/方向転換
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
# Linksee Memory Skill — エージェントの過去と未来をつなぐ
|
|
20
|
+
|
|
21
|
+
## 🧠 Core Principle
|
|
22
|
+
|
|
23
|
+
**このスキルは「エージェントの成長が session を跨いで永続するための唯一の手段」**。
|
|
24
|
+
|
|
25
|
+
Claude Code は session が終わると全部忘れる。Michieさんが昨日教えてくれた解決策、今日やった失敗、3日前の決定——すべて普通は消える。**linksee-memory は「消えない記憶」を作る装置**。
|
|
26
|
+
|
|
27
|
+
書き込みは Stop hook が自動でやってくれる(もう動いてる)。でも**読み出しはエージェントが能動的にやらないと使われない**。この skill がその「読みにいく習慣」をエージェントに植え付ける。
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 📐 6レイヤーの役割分担
|
|
32
|
+
|
|
33
|
+
どのレイヤーに記録するかで、後の検索精度が変わる。
|
|
34
|
+
|
|
35
|
+
| レイヤー | いつ使うか | 例 |
|
|
36
|
+
|---|---|---|
|
|
37
|
+
| 🎯 `goal` | ユーザーが明確なゴールを言ったとき | "freeeと連携させたい" "npm publishしたい" |
|
|
38
|
+
| 📍 `context` | いつ・なぜそれをしてるかの背景 | "X社との商談が水曜にあるから" |
|
|
39
|
+
| 💭 `emotion` | ユーザーの温度感・感情 | "疲れた" "嬉しい" "焦ってる" |
|
|
40
|
+
| 🔧 `implementation` | コードを書いた、設定した、動いた/動かなかった | 成功: "OAuth flow が通った" / 失敗: "auth_expired で止まった" |
|
|
41
|
+
| ⚠️ `caveat` | **二度と繰り返したくない教訓**(忘却保護) | "freeeのOAuthは24hで切れる" "このファイルは絶対編集しない" |
|
|
42
|
+
| 📈 `learning` | 新しいこと学んだ、前の考えが更新された | "AST chunking の方が line diff より効く" |
|
|
43
|
+
|
|
44
|
+
**重要:** `caveat` は自動で忘却保護される。痛みの記録は絶対消えない。
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
## 🔄 実行フロー(5つのタイミング)
|
|
49
|
+
|
|
50
|
+
### ① Task Start — 作業開始前に必ず recall
|
|
51
|
+
|
|
52
|
+
新しい作業を始める**前**に、過去のコンテキストを注入する。
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
mcp__linksee__recall({
|
|
56
|
+
query: "<現タスクのキーワード。プロジェクト名 + 技術名>",
|
|
57
|
+
max_tokens: 2000
|
|
58
|
+
})
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
**例**: ユーザーが「KanseiLinkに新しいツール追加したい」と言ったら:
|
|
62
|
+
```
|
|
63
|
+
recall({ query: "KanseiLink new tool", max_tokens: 2000 })
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
返ってきた memories から、特に以下に注目:
|
|
67
|
+
- **`caveat` 層** — 絶対避けるべき罠
|
|
68
|
+
- **`learning` 層** — 前に得た結論
|
|
69
|
+
- **`implementation.failure`** — 過去の失敗パターン
|
|
70
|
+
|
|
71
|
+
**例の結果の使い方:**
|
|
72
|
+
```
|
|
73
|
+
過去の caveat から: "同じMCPのtool名の衝突に気をつけろ"
|
|
74
|
+
→ 新しいツール追加前に既存tool名を確認する流れで作業開始
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### ② File Edit — ファイル編集前に recall_file
|
|
78
|
+
|
|
79
|
+
特定ファイルを触る前に、そのファイルの過去の編集履歴を確認:
|
|
80
|
+
|
|
81
|
+
```
|
|
82
|
+
mcp__linksee__recall_file({
|
|
83
|
+
path_substring: "<ファイルのパス or 部分一致する名前>",
|
|
84
|
+
max_intents: 5
|
|
85
|
+
})
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
返ってくる: そのファイルの全編集履歴 + **各編集を引き起こしたユーザー発言**
|
|
89
|
+
|
|
90
|
+
**これがキモ**: Mem0/Lettaにはない機能。「このファイル、前になぜ変更されたか」が残ってる。
|
|
91
|
+
|
|
92
|
+
### ③ Before Reading — 既読ファイルなら read_smart
|
|
93
|
+
|
|
94
|
+
ファイルを読む必要があるとき、**Read ツールの代わりに read_smart を使う**:
|
|
95
|
+
|
|
96
|
+
```
|
|
97
|
+
mcp__linksee__read_smart({
|
|
98
|
+
path: "<絶対パス>"
|
|
99
|
+
})
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
**効果**:
|
|
103
|
+
- 初回読み: 通常 Read と同じトークン(chunk metadata 付き)
|
|
104
|
+
- 2回目以降・変更なし: **~50 トークンだけ返る**(99% 節約)
|
|
105
|
+
- 2回目以降・変更あり: 変更 chunk だけ返る(50-90% 節約)
|
|
106
|
+
|
|
107
|
+
特に大きなファイル(1000行超えるもの)で効果絶大。
|
|
108
|
+
|
|
109
|
+
### ④ Failure — エラー発生時に caveat 記録
|
|
110
|
+
|
|
111
|
+
エラー・失敗・「うまくいかない」が発生した瞬間、すぐ記録する:
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
mcp__linksee__remember({
|
|
115
|
+
entity_name: "<プロジェクト名 or サービス名>",
|
|
116
|
+
entity_kind: "project",
|
|
117
|
+
layer: "caveat",
|
|
118
|
+
content: '{"rule_or_warning":"<失敗内容 + 回避策>","when":"<ISO日時>"}',
|
|
119
|
+
importance: 0.8 // 失敗は重要度高め
|
|
120
|
+
})
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**例**:
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"rule_or_warning": "freee MCPは24時間でOAuth token切れる。refresh_token使って再取得する必要あり。access_tokenを直接使い回すと401で止まる",
|
|
127
|
+
"from_incident": "session 02759-...で auth_expired エラー",
|
|
128
|
+
"workaround": "24h毎に refresh token → 新しい access token"
|
|
129
|
+
}
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
**なぜ重要か**: `caveat` は**自動で忘却保護**される。この記録があれば、別セッションの別エージェントも同じ失敗を避けられる。
|
|
133
|
+
|
|
134
|
+
### ⑤ Success/Learning — 成功・学習時に記録
|
|
135
|
+
|
|
136
|
+
新しいこと理解した、アプローチ変えた、問題解決した瞬間:
|
|
137
|
+
|
|
138
|
+
```
|
|
139
|
+
mcp__linksee__remember({
|
|
140
|
+
entity_name: "<entity>",
|
|
141
|
+
entity_kind: "project | concept | ...",
|
|
142
|
+
layer: "learning",
|
|
143
|
+
content: '{"at":"<日時>","learned":"<何を学んだか>","prior_belief":"<前はこう思ってた>"}',
|
|
144
|
+
importance: 0.7
|
|
145
|
+
})
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
`prior_belief` を書くことで「**信念の更新履歴**」が残る。これは後で「なぜこの決定をしたのか」の根拠になる。
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
## 🎯 絶対ルール
|
|
153
|
+
|
|
154
|
+
### ✅ やるべきこと
|
|
155
|
+
|
|
156
|
+
1. **新タスク開始時、必ず最初に `recall` を呼ぶ**(たとえ短くても)
|
|
157
|
+
2. **同じファイルを触る前に `recall_file` で過去履歴を確認**
|
|
158
|
+
3. **大きなファイルは `Read` より `read_smart` を優先**
|
|
159
|
+
4. **エラーが出たら即座に `caveat` 記録**(その場で記録、後回しにしない)
|
|
160
|
+
5. **ユーザーが驚いたり「なるほど」と言ったら `learning` 記録**
|
|
161
|
+
|
|
162
|
+
### ❌ やってはいけないこと
|
|
163
|
+
|
|
164
|
+
1. ❌ 作業開始時に recall せず、いきなり手を動かす
|
|
165
|
+
2. ❌ エラーをその場で解決したのに記録しない → 未来の自分(or 他のエージェント)が同じ失敗を繰り返す
|
|
166
|
+
3. ❌ `Read` ばかり使って `read_smart` を使わない(トークン無駄)
|
|
167
|
+
4. ❌ caveat をふざけた軽い tone で書く(真面目に残す)
|
|
168
|
+
5. ❌ 長期作業中は consolidate を忘れない(週1は `consolidate()` 呼ぶべき)
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## 🔁 Consolidate — 記憶の定期整理
|
|
173
|
+
|
|
174
|
+
メモリが膨張してきたら(目安: DB 20MB超、memories 15,000件超):
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
mcp__linksee__consolidate({
|
|
178
|
+
scope: "session",
|
|
179
|
+
min_age_days: 7
|
|
180
|
+
})
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
これで 7日前より古く、importance低く、cold バンドになった memories が自動でクラスタ化 → learning 層に1件に圧縮 → 元データ削除。
|
|
184
|
+
|
|
185
|
+
**caveat と active goal は消えない**。睡眠中の脳の記憶整理と同じ。
|
|
186
|
+
|
|
187
|
+
---
|
|
188
|
+
|
|
189
|
+
## 🧭 Skill 発火シナリオ集
|
|
190
|
+
|
|
191
|
+
### Case A: 新しいプロジェクトに入る
|
|
192
|
+
|
|
193
|
+
ユーザー: "今日は XYZ プロジェクトに戻るよ"
|
|
194
|
+
|
|
195
|
+
```
|
|
196
|
+
1. recall({ query: "XYZ", max_tokens: 2500 })
|
|
197
|
+
2. 返ってきた caveat/learning/goal を確認
|
|
198
|
+
3. ユーザーに「前回の続きで...」と状況を1行で示す
|
|
199
|
+
4. その文脈の上で作業開始
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Case B: 同じエラーが出た(デジャブ感)
|
|
203
|
+
|
|
204
|
+
ユーザー: "あれ、このエラー前も見たような..."
|
|
205
|
+
|
|
206
|
+
```
|
|
207
|
+
1. recall({ query: "<エラーメッセージの核キーワード>", max_tokens: 1000 })
|
|
208
|
+
2. 過去の caveat から workaround 取得
|
|
209
|
+
3. 「前回(日時)同じエラーで、X で解決した」と回答
|
|
210
|
+
4. workaround を適用
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
### Case C: ファイル編集前の確認
|
|
214
|
+
|
|
215
|
+
ユーザー: "server.ts を直して"
|
|
216
|
+
|
|
217
|
+
```
|
|
218
|
+
1. recall_file({ path_substring: "server.ts" })
|
|
219
|
+
2. 過去の編集頻度・理由を確認
|
|
220
|
+
3. 「このファイル過去 N 回編集されてる。最後は ○○ 目的」と報告
|
|
221
|
+
4. その文脈で今回の編集を行う
|
|
222
|
+
5. 編集後、implementation.success / failure で記録
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
### Case D: 決定した瞬間
|
|
226
|
+
|
|
227
|
+
ユーザー: "じゃあ Sonnet に切り替えるわ"
|
|
228
|
+
|
|
229
|
+
```
|
|
230
|
+
1. remember({
|
|
231
|
+
entity_name: "<プロジェクト>",
|
|
232
|
+
entity_kind: "project",
|
|
233
|
+
layer: "learning",
|
|
234
|
+
content: '{"at":"...", "learned":"このプロジェクトは Sonnet で行く", "prior_belief":"Opus使ってた"}',
|
|
235
|
+
importance: 0.8
|
|
236
|
+
})
|
|
237
|
+
2. 「記録しました」と一言
|
|
238
|
+
3. 次からの作業は Sonnet 前提で進める
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
### Case E: 長時間作業の終盤
|
|
242
|
+
|
|
243
|
+
ユーザー: "今日はここまで"
|
|
244
|
+
|
|
245
|
+
```
|
|
246
|
+
1. 今日のハイライトを remember で記録:
|
|
247
|
+
- 主要な decision を learning 層
|
|
248
|
+
- 発生した失敗を caveat 層
|
|
249
|
+
- 完成した成果物を implementation.success
|
|
250
|
+
2. 「記録完了。次回 recall で取れる状態です」と報告
|
|
251
|
+
3. 必要なら consolidate({scope:"session", min_age_days: 14}) を提案
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
### Case F: ユーザーが「覚えて」と明示
|
|
255
|
+
|
|
256
|
+
ユーザー: "これは覚えておいて: cloudsign より DocuSign の方が安定"
|
|
257
|
+
|
|
258
|
+
```
|
|
259
|
+
1. remember({
|
|
260
|
+
entity_name: "cloudsign vs DocuSign",
|
|
261
|
+
entity_kind: "concept",
|
|
262
|
+
layer: "caveat",
|
|
263
|
+
content: '{"rule_or_warning":"cloudsign (61% success) より DocuSign-JP (100%) の方が安定。カスタマーに提案するときは DocuSign 推奨"}',
|
|
264
|
+
importance: 0.9 // ユーザー明示指示は高優先度
|
|
265
|
+
})
|
|
266
|
+
2. 「記憶しました。caveat 層なので忘れません」と確認
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
---
|
|
270
|
+
|
|
271
|
+
## 🔐 プライバシー(ユーザーに聞かれたとき)
|
|
272
|
+
|
|
273
|
+
linksee-memory は **完全ローカル**:
|
|
274
|
+
- DB: `~/.linksee-memory/memory.db` (ユーザーのPC内)
|
|
275
|
+
- 外部送信: なし(telemetry は opt-in、デフォルト OFF)
|
|
276
|
+
- バックアップ: ファイルコピーで完結
|
|
277
|
+
|
|
278
|
+
「私たちのデータは外に出てる?」と聞かれたら:
|
|
279
|
+
「**デフォルトで一切出てません。** telemetry を明示的に enable していない限り、すべてローカルDB。`~/.linksee-memory/memory.db` のコピーが唯一のバックアップ。」と答える。
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## 🚀 KanseiLink Skill との連携
|
|
284
|
+
|
|
285
|
+
KanseiLink skill と linksee-memory skill は**セットで動く**と最大効果:
|
|
286
|
+
|
|
287
|
+
```
|
|
288
|
+
ユーザー: "freeeで請求書作って"
|
|
289
|
+
↓
|
|
290
|
+
[linksee-memory skill 発火] recall({query: "freee"})
|
|
291
|
+
→ 過去の caveat: "company_id 最初に取る必要あり"
|
|
292
|
+
→ 過去の learning: "OAuth 24h refresh"
|
|
293
|
+
↓
|
|
294
|
+
[kansei-link skill 発火] search_services({intent: "invoice"})
|
|
295
|
+
→ freee verified、trust 0.9
|
|
296
|
+
→ get_service_tips で pitfall 確認
|
|
297
|
+
↓
|
|
298
|
+
両方の集合知を持った状態で実装開始
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
**KanseiLink = 外部SaaSの集合知 / linksee-memory = 自分の過去の集合知**。両輪。
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## 📊 使うほど精度が上がる原理
|
|
306
|
+
|
|
307
|
+
| 時点 | recall 精度 | なぜ |
|
|
308
|
+
|---|---|---|
|
|
309
|
+
| Day 1 | 低(データ少) | Stop hook が貯めてる最中 |
|
|
310
|
+
| Week 1 | 中 | 数千件 memories、FTS5 が効き出す |
|
|
311
|
+
| Month 1 | 高 | heat_score が安定、重要メモリが浮上 |
|
|
312
|
+
| Month 3+ | 最強 | consolidate 走って、learnings が結晶化 |
|
|
313
|
+
|
|
314
|
+
**「使うほど賢くなる」は時間が味方してくれる**。今日の記録は 3ヶ月後の自分が読む。
|
|
315
|
+
|
|
316
|
+
---
|
|
317
|
+
|
|
318
|
+
*このスキルは linksee-memory MCP v0.0.5+ の上で動く。*
|
|
319
|
+
*Stop hook 経由で自動記録、recall 経由で手動取り出し。*
|
|
320
|
+
*MCP Registry 登録済み、Glama/LobeHub 申請中(2026-04-17 時点)*
|
|
321
|
+
*MIT License — Synapse Arrows PTE. LTD.*
|
package/package.json
CHANGED
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "linksee-memory",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.8",
|
|
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",
|
|
7
7
|
"bin": {
|
|
8
8
|
"linksee-memory": "./dist/mcp/server.js",
|
|
9
9
|
"linksee-memory-import": "./dist/bin/import-sessions.js",
|
|
10
|
-
"linksee-memory-sync": "./dist/bin/sync-session.js"
|
|
10
|
+
"linksee-memory-sync": "./dist/bin/sync-session.js",
|
|
11
|
+
"linksee-memory-install-skill": "./dist/bin/install-skill.js"
|
|
11
12
|
},
|
|
12
13
|
"main": "./dist/mcp/server.js",
|
|
13
14
|
"files": [
|
|
14
15
|
"dist/**/*.js",
|
|
15
16
|
"dist/**/*.d.ts",
|
|
16
17
|
"dist/db/schema.sql",
|
|
18
|
+
"dist/skill/SKILL.md",
|
|
17
19
|
"README.md",
|
|
18
20
|
"LICENSE"
|
|
19
21
|
],
|
|
20
22
|
"scripts": {
|
|
21
|
-
"build": "tsc && node -e \"require('fs').copyFileSync('src/db/schema.sql','dist/db/schema.sql')\"",
|
|
23
|
+
"build": "tsc && node -e \"require('fs').copyFileSync('src/db/schema.sql','dist/db/schema.sql'); require('fs').mkdirSync('dist/skill',{recursive:true}); require('fs').copyFileSync('src/skill/SKILL.md','dist/skill/SKILL.md')\"",
|
|
22
24
|
"start": "node dist/mcp/server.js",
|
|
23
25
|
"dev": "tsx src/mcp/server.ts",
|
|
24
26
|
"migrate": "node dist/db/migrate.js",
|