@pcircle/memesh 4.5.1 → 4.6.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 (169) hide show
  1. package/.claude-plugin/marketplace.json +5 -3
  2. package/.claude-plugin/plugin.json +6 -4
  3. package/AGENTS.md +95 -0
  4. package/README.de.md +129 -35
  5. package/README.md +161 -34
  6. package/README.zh-TW.md +130 -35
  7. package/dashboard/dist/index.html +10 -10
  8. package/dist/cli/view-live.js +3 -3
  9. package/dist/core/auto-tagger.d.ts.map +1 -1
  10. package/dist/core/auto-tagger.js +4 -9
  11. package/dist/core/auto-tagger.js.map +1 -1
  12. package/dist/core/briefing.d.ts +8 -0
  13. package/dist/core/briefing.d.ts.map +1 -0
  14. package/dist/core/briefing.js +91 -0
  15. package/dist/core/briefing.js.map +1 -0
  16. package/dist/core/capture-flag.d.ts +5 -0
  17. package/dist/core/capture-flag.d.ts.map +1 -0
  18. package/dist/core/capture-flag.js +10 -0
  19. package/dist/core/capture-flag.js.map +1 -0
  20. package/dist/core/conflict-candidates.d.ts +20 -0
  21. package/dist/core/conflict-candidates.d.ts.map +1 -0
  22. package/dist/core/conflict-candidates.js +79 -0
  23. package/dist/core/conflict-candidates.js.map +1 -0
  24. package/dist/core/conflict-judge.d.ts +47 -0
  25. package/dist/core/conflict-judge.d.ts.map +1 -0
  26. package/dist/core/conflict-judge.js +189 -0
  27. package/dist/core/conflict-judge.js.map +1 -0
  28. package/dist/core/digest-validator.d.ts.map +1 -1
  29. package/dist/core/digest-validator.js +3 -5
  30. package/dist/core/digest-validator.js.map +1 -1
  31. package/dist/core/doctor.d.ts +2 -0
  32. package/dist/core/doctor.d.ts.map +1 -1
  33. package/dist/core/doctor.js +34 -56
  34. package/dist/core/doctor.js.map +1 -1
  35. package/dist/core/dreamer.d.ts +5 -2
  36. package/dist/core/dreamer.d.ts.map +1 -1
  37. package/dist/core/dreamer.js +108 -25
  38. package/dist/core/dreamer.js.map +1 -1
  39. package/dist/core/embedder.d.ts +5 -4
  40. package/dist/core/embedder.d.ts.map +1 -1
  41. package/dist/core/embedder.js +16 -8
  42. package/dist/core/embedder.js.map +1 -1
  43. package/dist/core/failure-analyzer.d.ts.map +1 -1
  44. package/dist/core/failure-analyzer.js +7 -12
  45. package/dist/core/failure-analyzer.js.map +1 -1
  46. package/dist/core/install-channel.d.ts +1 -1
  47. package/dist/core/install-channel.d.ts.map +1 -1
  48. package/dist/core/install-channel.js +16 -5
  49. package/dist/core/install-channel.js.map +1 -1
  50. package/dist/core/install-hooks.d.ts +5 -0
  51. package/dist/core/install-hooks.d.ts.map +1 -1
  52. package/dist/core/install-hooks.js +0 -0
  53. package/dist/core/install-hooks.js.map +1 -1
  54. package/dist/core/json-utils.d.ts +1 -0
  55. package/dist/core/json-utils.d.ts.map +1 -1
  56. package/dist/core/json-utils.js +19 -10
  57. package/dist/core/json-utils.js.map +1 -1
  58. package/dist/core/kg-backfill.d.ts +0 -1
  59. package/dist/core/kg-backfill.d.ts.map +1 -1
  60. package/dist/core/kg-backfill.js +0 -3
  61. package/dist/core/kg-backfill.js.map +1 -1
  62. package/dist/core/lifecycle.d.ts.map +1 -1
  63. package/dist/core/lifecycle.js +14 -21
  64. package/dist/core/lifecycle.js.map +1 -1
  65. package/dist/core/memory-tool.d.ts.map +1 -1
  66. package/dist/core/memory-tool.js +4 -4
  67. package/dist/core/memory-tool.js.map +1 -1
  68. package/dist/core/operations.d.ts.map +1 -1
  69. package/dist/core/operations.js +22 -13
  70. package/dist/core/operations.js.map +1 -1
  71. package/dist/core/prompt-safety.d.ts +1 -0
  72. package/dist/core/prompt-safety.d.ts.map +1 -1
  73. package/dist/core/prompt-safety.js +7 -0
  74. package/dist/core/prompt-safety.js.map +1 -1
  75. package/dist/core/schema-export.d.ts.map +1 -1
  76. package/dist/core/schema-export.js +31 -0
  77. package/dist/core/schema-export.js.map +1 -1
  78. package/dist/core/setup.d.ts +29 -0
  79. package/dist/core/setup.d.ts.map +1 -0
  80. package/dist/core/setup.js +127 -0
  81. package/dist/core/setup.js.map +1 -0
  82. package/dist/core/task-state-store.d.ts +17 -0
  83. package/dist/core/task-state-store.d.ts.map +1 -0
  84. package/dist/core/task-state-store.js +45 -0
  85. package/dist/core/task-state-store.js.map +1 -0
  86. package/dist/core/task-state.d.ts +19 -0
  87. package/dist/core/task-state.d.ts.map +1 -0
  88. package/dist/core/task-state.js +91 -0
  89. package/dist/core/task-state.js.map +1 -0
  90. package/dist/core/time-utils.d.ts +2 -0
  91. package/dist/core/time-utils.d.ts.map +1 -0
  92. package/dist/core/time-utils.js +14 -0
  93. package/dist/core/time-utils.js.map +1 -0
  94. package/dist/core/title.d.ts +5 -0
  95. package/dist/core/title.d.ts.map +1 -0
  96. package/dist/core/title.js +14 -0
  97. package/dist/core/title.js.map +1 -0
  98. package/dist/core/transcript-source.d.ts.map +1 -1
  99. package/dist/core/transcript-source.js +2 -3
  100. package/dist/core/transcript-source.js.map +1 -1
  101. package/dist/core/types.d.ts +4 -0
  102. package/dist/core/types.d.ts.map +1 -1
  103. package/dist/core/work-topology.d.ts +33 -0
  104. package/dist/core/work-topology.d.ts.map +1 -0
  105. package/dist/core/work-topology.js +183 -0
  106. package/dist/core/work-topology.js.map +1 -0
  107. package/dist/db.d.ts +2 -7
  108. package/dist/db.d.ts.map +1 -1
  109. package/dist/db.js +144 -284
  110. package/dist/db.js.map +1 -1
  111. package/dist/knowledge-graph.d.ts +1 -0
  112. package/dist/knowledge-graph.d.ts.map +1 -1
  113. package/dist/knowledge-graph.js +50 -40
  114. package/dist/knowledge-graph.js.map +1 -1
  115. package/dist/skills-manifest.json +48 -18
  116. package/dist/storage/conflicts.d.ts.map +1 -1
  117. package/dist/storage/conflicts.js +2 -7
  118. package/dist/storage/conflicts.js.map +1 -1
  119. package/dist/storage/fts-index.d.ts +4 -2
  120. package/dist/storage/fts-index.d.ts.map +1 -1
  121. package/dist/storage/fts-index.js +16 -4
  122. package/dist/storage/fts-index.js.map +1 -1
  123. package/dist/storage/schema.d.ts +20 -0
  124. package/dist/storage/schema.d.ts.map +1 -0
  125. package/dist/storage/schema.js +274 -0
  126. package/dist/storage/schema.js.map +1 -0
  127. package/dist/transports/cli/cli.d.ts +1 -4
  128. package/dist/transports/cli/cli.d.ts.map +1 -1
  129. package/dist/transports/cli/cli.js +382 -6
  130. package/dist/transports/cli/cli.js.map +1 -1
  131. package/dist/transports/http/server.d.ts.map +1 -1
  132. package/dist/transports/http/server.js +208 -307
  133. package/dist/transports/http/server.js.map +1 -1
  134. package/dist/transports/mcp/handlers.d.ts +46 -0
  135. package/dist/transports/mcp/handlers.d.ts.map +1 -1
  136. package/dist/transports/mcp/handlers.js +57 -2
  137. package/dist/transports/mcp/handlers.js.map +1 -1
  138. package/dist/transports/schemas.d.ts +21 -10
  139. package/dist/transports/schemas.d.ts.map +1 -1
  140. package/dist/transports/schemas.js +26 -8
  141. package/dist/transports/schemas.js.map +1 -1
  142. package/llms-install.md +138 -0
  143. package/package.json +14 -9
  144. package/scripts/hooks/_generated/capture-flag.js +17 -0
  145. package/scripts/hooks/_generated/fts-index.js +16 -4
  146. package/scripts/hooks/_generated/schema.js +281 -0
  147. package/scripts/hooks/_generated/task-state.js +98 -0
  148. package/scripts/hooks/_generated/time-utils.js +21 -0
  149. package/scripts/hooks/_generated/title.js +21 -0
  150. package/scripts/hooks/_generated/work-topology.js +190 -0
  151. package/scripts/hooks/_shared.js +122 -478
  152. package/scripts/hooks/post-commit.js +4 -1
  153. package/scripts/hooks/pre-compact.js +13 -1
  154. package/scripts/hooks/pre-edit-recall.js +5 -3
  155. package/scripts/hooks/session-start.js +135 -59
  156. package/scripts/hooks/session-summary.js +59 -24
  157. package/skills/memesh/SKILL.md +97 -76
  158. package/README.es.md +0 -467
  159. package/README.fr.md +0 -459
  160. package/README.ja.md +0 -467
  161. package/README.ko.md +0 -467
  162. package/README.pt.md +0 -459
  163. package/README.th.md +0 -460
  164. package/README.vi.md +0 -459
  165. package/README.zh-CN.md +0 -466
  166. package/dist/cli/view.d.ts +0 -3
  167. package/dist/cli/view.d.ts.map +0 -1
  168. package/dist/cli/view.js +0 -523
  169. package/dist/cli/view.js.map +0 -1
@@ -1,12 +1,12 @@
1
1
  ---
2
2
  name: memesh
3
- description: Use MeMesh to remember, recall, and manage AI knowledge across sessions. Triggers when the user asks to remember something, recall past decisions, forget outdated info, learn from mistakes, or analyze work patterns. Also triggers proactively when you make important decisions, fix bugs, or learn lessons worth preserving.
3
+ description: Use MeMesh to remember, recall, and manage AI knowledge across sessions. Triggers when the user asks to remember something, recall past decisions, forget outdated info, learn from mistakes, or analyze work patterns. Also triggers when the user asks "what do you remember", "where did we leave off", or wants to catch up on a project; when a session starts and project context is needed; and proactively when you make important decisions, fix bugs, or learn lessons worth preserving.
4
4
  user-invocable: true
5
5
  ---
6
6
 
7
7
  # MeMesh — AI Memory Management
8
8
 
9
- Persistent memory layer for AI agents. Remember decisions, recall context, learn from mistakesacross sessions.
9
+ Persistent memory for AI agents. The point is continuity: the next session starts where this one stopped, instead of re-spending thousands of tokens re-discovering project state and the human never has to re-explain it.
10
10
 
11
11
  ## How to Access (auto-detect)
12
12
 
@@ -23,39 +23,74 @@ Persistent memory layer for AI agents. Remember decisions, recall context, learn
23
23
 
24
24
  All examples below use CLI. MCP tools accept the same parameters as JSON objects.
25
25
 
26
+ ## The Loop
27
+
28
+ Four moments. Everything else in this file is detail.
29
+
30
+ **SESSION START → load the briefing (once).**
31
+ Call the `briefing` MCP tool or run `memesh briefing`. It returns the assembled
32
+ work topology: where the work was left off (goal / next / blocked / done),
33
+ decisions and direction, lessons not to repeat, what is known, recent activity.
34
+ One call is cheaper than re-exploring the repo to reconstruct the same picture.
35
+ Exception: under Claude Code the session-start hook has ALREADY injected this
36
+ exact block — do not call it again (see "What's Already Automatic").
37
+
38
+ **USER STATES a goal, next step, or blocker → record it immediately.**
39
+ ```bash
40
+ memesh task --goal "Ship the work-topology injection" --next "Open the PR once CI is green"
41
+ memesh task --blocked "Waiting on the Windows runner"
42
+ memesh task --blocked "" # blocker resolved — empty string clears the field
43
+ ```
44
+ Fields: `--goal` `--next` `--blocked` `--done` (MCP tool: `task_state`).
45
+ Record ONLY what the user actually said. This state is injected at the top of
46
+ the next session and read as fact — a goal you guessed from which files were
47
+ edited reaches that session with nothing to correct it. If it was not said,
48
+ leave the field out.
49
+
50
+ **SESSION END or milestone → make the task state match reality.**
51
+ `memesh task` (no flags) shows exactly what the next session will be told.
52
+ If "next" is now done, record what is actually next; if the blocker cleared,
53
+ clear it.
54
+
55
+ **USER ASKS "what do you remember / where were we" → briefing, then relay.**
56
+ Run `memesh briefing` (or `--project <name>`) and answer from it. For specific
57
+ follow-up questions, use `recall`.
58
+
26
59
  ## What's Already Automatic (Claude Code Plugin Hooks)
27
60
 
28
61
  If MeMesh is installed as a Claude Code plugin, these happen **without any action from you**:
29
62
 
30
63
  | Hook | When | What it does |
31
64
  |------|------|-------------|
32
- | **SessionStart** | Every session begins | Auto-recalls top memories for current project + surfaces lesson warnings |
33
- | **PreToolUse (Edit)** | Before editing files | Injects memories related to the file or project |
34
- | **UserPromptSubmit** | When you submit a prompt | Detects "remember this" intent (5 languages: en, es, fr, pt, zh-TW) and reminds Claude to use memesh |
35
- | **PostToolUse (Commit)** | After `git commit` | Auto-tracks commit with diff stats as a memory entity |
65
+ | **SessionStart** | Every session begins | Injects the briefing: task state → lessons → project memories recent activity |
66
+ | **PreToolUse (Edit/Write)** | Before editing files | Injects memories related to the file or project |
67
+ | **UserPromptSubmit** | When you submit a prompt | Detects "remember this" intent (5 languages) and reminds Claude to use memesh |
68
+ | **PostToolUse (Bash)** | After `git commit` | Auto-tracks the commit with diff stats as a memory entity |
36
69
  | **Stop** | Session ends | Auto-captures session knowledge + runs LLM failure analysis → lessons |
37
- | **PreCompact** | Before context compaction | Saves important knowledge before conversation history is compressed |
70
+ | **PreCompact** | Before context compaction | Saves important knowledge before history is compressed |
38
71
 
39
- **You do NOT need to manually:**
40
- - Recall at session start (SessionStart hook does it)
41
- - Remember commits (PostToolUse hook does it)
42
- - Summarize sessions (Stop hook does it)
43
- - Remember when you say "記下來" / "remember this" (UserPromptSubmit hook reminds Claude)
72
+ Because of the SessionStart hook: **in Claude Code, do NOT call `briefing` at
73
+ session start it is already in your context.** Call it only mid-session
74
+ (context was compacted, or the user asks what you remember) or on hosts
75
+ without these hooks (other MCP clients, shell-only agents). Double-injection
76
+ spends the very tokens this system exists to save.
44
77
 
45
- **You DO need to manually** use the commands below for intentional knowledge management.
78
+ Hooks capture what *happened*. You still act manually for what they cannot
79
+ know: what the user **meant** (task state), deliberate decisions and lessons,
80
+ and retiring outdated info.
46
81
 
47
- ## When to Use
48
-
49
- ### Proactive triggers — do these WITHOUT being asked
82
+ ## Proactive triggers — do these WITHOUT being asked
50
83
 
51
84
  | Situation | Action |
52
85
  |-----------|--------|
86
+ | User states what they're working on / what's next / what's blocking | `memesh task --goal "…"` / `--next "…"` / `--blocked "…"` |
53
87
  | Design decision made | `memesh remember --name "auth-choice" --type decision --obs "Use OAuth 2.0 with PKCE" --tags "project:myapp"` |
54
88
  | Bug fixed | `memesh learn --error "what broke" --fix "what fixed it" --root-cause "why" --severity major` |
55
- | Pattern established | `memesh remember --name "validation-pattern" --type pattern --obs "Always use Zod"` |
56
89
  | Starting work on a feature | `memesh recall "feature-name" --json` |
57
90
  | User asks "what did we decide?" | `memesh recall "topic" --tag "project:myapp"` |
58
- | Info is outdated | `memesh forget --name "old-decision"` |
91
+ | User asks "where did we leave off?" | `memesh briefing` relay it |
92
+ | Info is outdated | New memory with `--supersedes "old-name"`, or `memesh forget` |
93
+ | Context about the user's work habits needed | `user_patterns` MCP tool (MCP/HTTP only — no CLI command) |
59
94
 
60
95
  ### When NOT to remember
61
96
  - Trivial implementation details (variable names, import paths)
@@ -69,83 +104,69 @@ If MeMesh is installed as a Claude Code plugin, these happen **without any actio
69
104
  memesh learn \
70
105
  --error "SIGSEGV when running vitest with threads" \
71
106
  --fix "Use pool: 'forks' instead of 'threads' for native modules" \
72
- --root-cause "better-sqlite3 native module is not thread-safe" \
73
- --prevention "Check if test framework supports native modules before choosing pool" \
107
+ --root-cause "the native module is not thread-safe" \
108
+ --prevention "Check if the test framework supports native modules before choosing pool" \
74
109
  --severity major
75
110
  ```
76
- This creates a `lesson_learned` entity. Lessons are surfaced as **proactive warnings** at next session start.
77
-
78
- ### You need context before working
79
- ```bash
80
- memesh recall "authentication" --json
81
- memesh recall --tag "project:myapp" --limit 10
82
- memesh recall --cross-project # search across all projects
83
- ```
84
- Results are ranked by relevance, recency, frequency, confidence, and recall impact.
111
+ Creates a `lesson_learned` entity. Lessons are surfaced as **proactive warnings** at the next session start.
85
112
 
86
113
  ### A decision was just made
87
114
  ```bash
88
115
  memesh remember \
89
- --name "db-choice-2026" \
90
- --type decision \
116
+ --name "db-choice" --type decision \
117
+ --title "SQLite for local-first storage" \
91
118
  --obs "Use SQLite for local-first" "Rejected PostgreSQL due to deployment complexity" \
92
119
  --tags "project:myapp" "topic:database"
93
120
  ```
121
+ Use a **stable name** (`db-choice`, not `db-choice-2026-08-16`): reusing the
122
+ name appends to the same entity instead of scattering duplicates. `--title` is
123
+ the human-readable headline; the name stays the machine key. If this replaces
124
+ an older decision, add `--supersedes "old-db-choice"`.
94
125
  Types: `decision` `pattern` `lesson_learned` `bug_fix` `architecture` `convention` `feature` `best_practice` `concept` `tool` `note`
95
126
 
96
- ### Old info needs updating
127
+ ### You need context on a specific topic
97
128
  ```bash
98
- memesh forget --name "old-auth-approach" # archive entire entity
99
- memesh forget --name "auth-approach" --observation "Use JWT" # remove one fact only
129
+ memesh recall "authentication" --json
130
+ memesh recall --tag "project:myapp" --limit 10
131
+ memesh recall --cross-project # search across all projects
100
132
  ```
101
- Archives (soft-delete). Never permanently removes.
133
+ Query words are OR-ed and ranked by relevance — a naturally phrased question
134
+ works; extra words narrow the ranking, not the result set.
102
135
 
103
- ### Memories are getting verbose
136
+ ### Old info needs updating
104
137
  ```bash
105
- memesh dream run --project myapp # propose digests for clusters of noisy memories
106
- memesh dream run --from-transcripts # OR: mine this project's Claude Code sessions for memory
107
- memesh dream list # review what it proposed
108
- memesh dream show <id> # inspect one proposal in full before accepting
109
- memesh dream accept <id> # apply one, or: memesh dream reject <id>
138
+ memesh forget --name "auth-approach" --observation "Use JWT" # remove one fact only
139
+ memesh forget --name "old-auth-approach" # archive the whole entity
110
140
  ```
111
- Nothing changes until a proposal is accepted, and sources are archived rather
112
- than deleted. Requires Smart Mode configured. Works on episodic memories
113
- (commits, session notes) — lessons, decisions, architecture notes and pinned
114
- entities are never touched.
141
+ Both are soft (recoverable) nothing is permanently removed.
115
142
 
116
- `memesh consolidate` was retired: it rewrote a memory with an LLM summary and
117
- deleted the originals on the spot, with no review step.
143
+ ### Memories are getting verbose or stale
144
+ Use the **memesh-review** skill: it analyzes health, finds stale, conflicting
145
+ and redundant memories, and proposes cleanup (including `memesh dream`, the
146
+ reviewed digest pipeline). Do not hand-compress memories yourself.
118
147
 
119
- ### Backup or share memories
148
+ ### Backup, share, health
120
149
  ```bash
121
150
  memesh export --tag "project:myapp" > memories.json
122
- memesh import memories.json --merge skip # skip | overwrite | append
123
- ```
124
-
125
- ### Check MeMesh health
126
- ```bash
127
- memesh status # version, search level, embeddings
128
- memesh config list # current configuration
151
+ memesh import memories.json --merge skip # skip | overwrite | append
152
+ memesh status # version, search level, embeddings
153
+ memesh reindex # rebuild embeddings after provider change
129
154
  ```
130
155
 
131
- ### Regenerate embeddings after provider change
132
- ```bash
133
- memesh reindex # rebuild all embeddings
134
- memesh reindex --namespace personal # reindex only one namespace
135
- memesh reindex --json # structured progress output
136
- ```
137
- Use this when you change embedding provider (e.g., Ollama OpenAI) or dimension. The database auto-drops old embeddings on provider change, but you need to run `reindex` to regenerate them for existing memories.
138
-
139
- ## MCP-Only Features
140
-
141
- These require MCP tools or the HTTP API (`memesh serve` + REST calls):
142
-
143
- - **user_patterns** Analyzes work patterns (schedule, tool preferences, strengths) from existing memories. Categories: `workSchedule`, `toolPreferences`, `strengths`, `focusAreas`.
144
-
145
- ## Best Practices
146
-
147
- 1. **Be specific** — "Use OAuth 2.0 with PKCE" not "auth stuff decided"
148
- 2. **Tag by project** — Always include `project:<name>` tag
149
- 3. **Use `--json`** — When you need to parse output programmatically
150
- 4. **Learn from every bug** — Every fix is a future warning. Use `learn`, not just `remember`.
151
- 5. **Don't over-remember** — Decisions that took > 5 minutes. Patterns worth preserving. Not trivia.
156
+ ## Memory hygiene
157
+
158
+ 1. **Stable names append.** Remembering under an existing name adds
159
+ observations and dedupes tags it never replaces the entity. Reuse the
160
+ name to grow one memory; do not mint `-v2` / dated variants of it.
161
+ 2. **`supersedes` retires the loser.** When a new memory replaces an old one,
162
+ record it with `--supersedes <old-name>` (MCP: a relation of type
163
+ `supersedes`). The old entity is archived — recoverable, out of recall.
164
+ 3. **`contradicts` flags real conflicts.** When two memories cannot both be
165
+ true and neither is clearly wrong yet, link them with `--contradicts`
166
+ (MCP: relation type `contradicts`). Both surface as a conflict on every
167
+ recall until someone resolves it.
168
+ 4. **Prefer observation-level forgetting.** `forget --observation "…"` removes
169
+ one wrong fact and keeps the entity. Plain `forget` archives the whole
170
+ entity out of visibility — use it only when everything in it is dead.
171
+ 5. **Tag by project** (`project:<name>`) and **be specific** — "Use OAuth 2.0
172
+ with PKCE", not "auth stuff decided".