@hir4ta/mneme 0.17.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 (43) hide show
  1. package/.claude-plugin/plugin.json +29 -0
  2. package/.mcp.json +18 -0
  3. package/README.ja.md +400 -0
  4. package/README.md +410 -0
  5. package/bin/mneme.js +203 -0
  6. package/dist/lib/db.js +340 -0
  7. package/dist/lib/fuzzy-search.js +214 -0
  8. package/dist/lib/github.js +121 -0
  9. package/dist/lib/similarity.js +193 -0
  10. package/dist/lib/utils.js +62 -0
  11. package/dist/public/apple-touch-icon.png +0 -0
  12. package/dist/public/assets/index-BgqCALAg.css +1 -0
  13. package/dist/public/assets/index-EMvn4VEa.js +330 -0
  14. package/dist/public/assets/react-force-graph-2d-DWoBaKmT.js +46 -0
  15. package/dist/public/favicon-128-max.png +0 -0
  16. package/dist/public/favicon-256-max.png +0 -0
  17. package/dist/public/favicon-32-max.png +0 -0
  18. package/dist/public/favicon-512-max.png +0 -0
  19. package/dist/public/favicon-64-max.png +0 -0
  20. package/dist/public/index.html +15 -0
  21. package/dist/server.js +4791 -0
  22. package/dist/servers/db-server.js +30558 -0
  23. package/dist/servers/search-server.js +30366 -0
  24. package/hooks/default-tags.json +1055 -0
  25. package/hooks/hooks.json +61 -0
  26. package/hooks/post-tool-use.sh +96 -0
  27. package/hooks/pre-compact.sh +187 -0
  28. package/hooks/session-end.sh +567 -0
  29. package/hooks/session-start.sh +380 -0
  30. package/hooks/user-prompt-submit.sh +253 -0
  31. package/package.json +77 -0
  32. package/servers/db-server.ts +993 -0
  33. package/servers/search-server.ts +675 -0
  34. package/skills/AGENTS.override.md +5 -0
  35. package/skills/harvest/skill.md +295 -0
  36. package/skills/init-mneme/skill.md +101 -0
  37. package/skills/plan/skill.md +422 -0
  38. package/skills/report/skill.md +74 -0
  39. package/skills/resume/skill.md +278 -0
  40. package/skills/review/skill.md +419 -0
  41. package/skills/save/skill.md +482 -0
  42. package/skills/search/skill.md +175 -0
  43. package/skills/using-mneme/skill.md +185 -0
@@ -0,0 +1,295 @@
1
+ ---
2
+ name: harvest
3
+ description: |
4
+ Extract knowledge from GitHub PR review comments and save to mneme's knowledge base.
5
+ Use when: (1) a PR has valuable review feedback, (2) learning from code review discussions,
6
+ (3) capturing team knowledge from merged PRs.
7
+ argument-hint: "<PR-URL>"
8
+ ---
9
+
10
+ # /mneme:harvest
11
+
12
+ Extract knowledge from GitHub PR review comments and save to mneme's knowledge base.
13
+
14
+ ## Usage
15
+
16
+ ```
17
+ /mneme:harvest https://github.com/owner/repo/pull/123
18
+ ```
19
+
20
+ ## What Gets Extracted
21
+
22
+ PR review comments are classified and saved to appropriate locations:
23
+
24
+ | Comment Type | Destination | Example |
25
+ |--------------|-------------|---------|
26
+ | Code style/format | `rules/dev-rules.json` | "Use early return pattern" |
27
+ | Best practices | `rules/review-guidelines.json` | "Always validate user input" |
28
+ | Design discussions | `decisions/` | Architecture choices with reasoning |
29
+ | Error/fix patterns | `patterns/` | Problem-solution pairs |
30
+
31
+ ## Execution Steps
32
+
33
+ ### 1. Parse and Validate URL
34
+
35
+ ```
36
+ Input: https://github.com/owner/repo/pull/123
37
+ Output: { owner, repo, prNumber, url }
38
+ ```
39
+
40
+ If URL is invalid, show error and exit.
41
+
42
+ ### 2. Fetch PR Comments
43
+
44
+ Use gh CLI to fetch all comments:
45
+
46
+ ```bash
47
+ # Review comments (on specific code lines)
48
+ gh api repos/{owner}/{repo}/pulls/{prNumber}/comments --paginate
49
+
50
+ # Issue comments (general PR comments)
51
+ gh api repos/{owner}/{repo}/issues/{prNumber}/comments --paginate
52
+ ```
53
+
54
+ ### 3. Classify Comments
55
+
56
+ For each comment, analyze content to determine type:
57
+
58
+ **Style/Format → dev-rules.json**
59
+ - Keywords: "style", "format", "naming", "convention", "indent", "spacing"
60
+ - Pattern: Prescriptive statements about code appearance
61
+
62
+ **Best Practice → review-guidelines.json**
63
+ - Keywords: "should", "always", "never", "avoid", "prefer", "best practice"
64
+ - Pattern: General coding guidance
65
+
66
+ **Design Discussion → decisions/**
67
+ - Keywords: "architecture", "design", "approach", "tradeoff", "alternative"
68
+ - Pattern: Choices between options with reasoning
69
+
70
+ **Error/Solution → patterns/**
71
+ - Keywords: "bug", "fix", "error", "issue", "problem", "solution"
72
+ - Pattern: Problem description followed by fix
73
+
74
+ **Skip if:**
75
+ - Comment is too short (< 20 characters)
76
+ - Comment is just acknowledgment ("LGTM", "Thanks", "Done")
77
+ - Comment is a question without answer
78
+
79
+ ### 4. Similarity Check
80
+
81
+ Before adding each item, check for duplicates and conflicts:
82
+
83
+ **Duplicate Detection (Jaccard similarity >= 0.9)**
84
+ ```
85
+ New: "Use early return pattern to reduce nesting"
86
+ Existing: "Prefer early return to reduce code nesting"
87
+ → DUPLICATE: Skip (similarity: 0.92)
88
+ ```
89
+
90
+ **Similar Item Warning (0.7 <= similarity < 0.9)**
91
+ ```
92
+ New: "Use async/await instead of callbacks"
93
+ Existing: "Prefer promises over callbacks"
94
+ → SIMILAR: Ask user to confirm
95
+ ```
96
+
97
+ **Conflict Detection**
98
+ ```
99
+ New: "Always use semicolons in JavaScript"
100
+ Existing: "Never use semicolons in JavaScript"
101
+ → CONFLICT: Ask user to resolve
102
+ ```
103
+
104
+ ### 5. User Confirmation
105
+
106
+ For each extracted item, present options:
107
+
108
+ ```
109
+ [Extracted from PR #123 comment by @user]
110
+
111
+ Type: dev-rule
112
+ Content: "Use early return pattern to reduce nesting"
113
+
114
+ Similarity check:
115
+ - Similar to existing rule "dev-001": "Prefer early return" (0.75)
116
+
117
+ Options:
118
+ 1. [Add] Add as new item
119
+ 2. [Skip] Don't add
120
+ 3. [Replace] Replace similar item
121
+ 4. [Merge] Combine with similar item
122
+ ```
123
+
124
+ ### 6. Save with PR Source
125
+
126
+ All saved items include `prSource` for traceability:
127
+
128
+ ```json
129
+ {
130
+ "id": "dev-2026-01-30-001",
131
+ "rule": "Use early return pattern to reduce nesting",
132
+ "category": "code-style",
133
+ "prSource": {
134
+ "owner": "hir4ta",
135
+ "repo": "mneme",
136
+ "prNumber": 42,
137
+ "url": "https://github.com/hir4ta/mneme/pull/42",
138
+ "commentId": 123456789
139
+ },
140
+ "createdAt": "2026-01-30T10:00:00Z"
141
+ }
142
+ ```
143
+
144
+ ### 7. Output Summary
145
+
146
+ ```markdown
147
+ # Harvest Summary: PR #123
148
+
149
+ **Source:** https://github.com/owner/repo/pull/123
150
+ **Comments analyzed:** 15
151
+ **Items extracted:** 8
152
+
153
+ ## Added
154
+ - [dev-rule] Use early return pattern
155
+ - [dev-rule] Prefer const over let
156
+ - [pattern] Fix: undefined check before access
157
+
158
+ ## Skipped (duplicate)
159
+ - "Use const" (similar to existing dev-003)
160
+
161
+ ## Skipped (user choice)
162
+ - Design discussion about API structure
163
+
164
+ ## Conflicts Detected
165
+ - None
166
+
167
+ ## PR Source References
168
+ All items saved with prSource linking to original comments.
169
+ ```
170
+
171
+ ## Output Formats
172
+
173
+ ### dev-rules.json Entry
174
+
175
+ ```json
176
+ {
177
+ "id": "dev-2026-01-30-001",
178
+ "category": "code-style",
179
+ "rule": "Use early return pattern to reduce nesting",
180
+ "severity": "warning",
181
+ "enabled": true,
182
+ "createdAt": "2026-01-30T10:00:00Z",
183
+ "prSource": {
184
+ "owner": "owner",
185
+ "repo": "repo",
186
+ "prNumber": 123,
187
+ "url": "https://github.com/owner/repo/pull/123",
188
+ "commentId": 123456789
189
+ }
190
+ }
191
+ ```
192
+
193
+ ### decisions/ Entry
194
+
195
+ ```json
196
+ {
197
+ "id": "dec-2026-01-30-001",
198
+ "title": "Use Repository Pattern for Data Access",
199
+ "decision": "Implement repository pattern for all database operations",
200
+ "reasoning": "Extracted from PR review discussion about separation of concerns",
201
+ "alternatives": [
202
+ { "name": "Direct DB access", "reason": "Simpler but harder to test" }
203
+ ],
204
+ "tags": ["architecture", "database"],
205
+ "status": "active",
206
+ "prSource": {
207
+ "owner": "owner",
208
+ "repo": "repo",
209
+ "prNumber": 123,
210
+ "url": "https://github.com/owner/repo/pull/123"
211
+ }
212
+ }
213
+ ```
214
+
215
+ ### patterns/ Entry
216
+
217
+ ```json
218
+ {
219
+ "id": "pat-2026-01-30-001",
220
+ "type": "error-solution",
221
+ "description": "Null check before property access",
222
+ "errorPattern": "Cannot read property 'x' of undefined",
223
+ "solution": "Add optional chaining or explicit null check",
224
+ "context": "Extracted from PR review fix",
225
+ "tags": ["javascript", "null-safety"],
226
+ "prSource": {
227
+ "owner": "owner",
228
+ "repo": "repo",
229
+ "prNumber": 123,
230
+ "url": "https://github.com/owner/repo/pull/123",
231
+ "commentId": 987654321
232
+ }
233
+ }
234
+ ```
235
+
236
+ ## Classification Guidelines
237
+
238
+ ### Identifying Comment Types
239
+
240
+ **Code Style/Format**
241
+ ```
242
+ ✓ "Please use camelCase for variable names"
243
+ ✓ "Add a blank line between function definitions"
244
+ ✓ "Indent with 2 spaces, not tabs"
245
+ ✗ "This logic seems wrong" (not style)
246
+ ```
247
+
248
+ **Best Practice**
249
+ ```
250
+ ✓ "Always validate user input before processing"
251
+ ✓ "Prefer composition over inheritance"
252
+ ✓ "Use meaningful variable names"
253
+ ✗ "Fix the typo" (not a general practice)
254
+ ```
255
+
256
+ **Design Discussion**
257
+ ```
258
+ ✓ "We should use event sourcing because..."
259
+ ✓ "The tradeoff between X and Y is..."
260
+ ✓ "I chose this approach over the alternative..."
261
+ ✗ "LGTM" (not a discussion)
262
+ ```
263
+
264
+ **Error/Solution Pattern**
265
+ ```
266
+ ✓ "This will cause a null pointer exception, use optional chaining"
267
+ ✓ "The bug is because X, fix by doing Y"
268
+ ✓ "This pattern causes memory leaks, use cleanup"
269
+ ✗ "There's a bug here" (no solution)
270
+ ```
271
+
272
+ ## Error Handling
273
+
274
+ **gh CLI not available:**
275
+ ```
276
+ Error: gh CLI not found. Please install GitHub CLI.
277
+ https://cli.github.com/
278
+ ```
279
+
280
+ **Not authenticated:**
281
+ ```
282
+ Error: Not authenticated to GitHub. Run `gh auth login`.
283
+ ```
284
+
285
+ **PR not found:**
286
+ ```
287
+ Error: PR #123 not found in owner/repo.
288
+ Check the URL and your access permissions.
289
+ ```
290
+
291
+ **No comments:**
292
+ ```
293
+ No review comments found in PR #123.
294
+ Nothing to harvest.
295
+ ```
@@ -0,0 +1,101 @@
1
+ ---
2
+ name: init-mneme
3
+ description: |
4
+ Initialize mneme in the current project by creating .mneme directory structure.
5
+ Use when: (1) setting up mneme in a new project, (2) the project doesn't have .mneme yet.
6
+ user-invocable: true
7
+ ---
8
+
9
+ # Initialize mneme
10
+
11
+ <instructions>
12
+ Create the `.mneme` directory structure in the current project.
13
+
14
+ 1. Check if `.mneme` already exists - if so, inform the user it's already initialized
15
+ 2. Create the directory structure:
16
+ - `.mneme/sessions/`
17
+ - `.mneme/rules/`
18
+ - `.mneme/patterns/`
19
+ - `.mneme/decisions/`
20
+ 3. Copy default tags from the plugin's `hooks/default-tags.json` to `.mneme/tags.json`
21
+ 4. Create `.mneme/.gitignore` to exclude local database:
22
+ ```
23
+ # Local SQLite database (private interactions)
24
+ local.db
25
+ local.db-wal
26
+ local.db-shm
27
+ ```
28
+ 5. Create empty rules files:
29
+ - `.mneme/rules/dev-rules.json`
30
+ - `.mneme/rules/review-guidelines.json`
31
+ 6. Initialize local SQLite database at `.mneme/local.db`
32
+ - Note: Data is stored locally within the project
33
+ - The local.db is gitignored (private interactions)
34
+
35
+ Use this JSON template for the rules files:
36
+ ```json
37
+ {
38
+ "schemaVersion": 1,
39
+ "createdAt": "<current ISO timestamp>",
40
+ "updatedAt": "<current ISO timestamp>",
41
+ "items": []
42
+ }
43
+ ```
44
+
45
+ For SQLite initialization (local database):
46
+ ```bash
47
+ # Local database location
48
+ MNEME_DIR=".mneme"
49
+
50
+ # Initialize with schema
51
+ sqlite3 "$MNEME_DIR/local.db" < /path/to/mneme/lib/schema.sql
52
+ ```
53
+
54
+ Or if schema.sql is not available, create minimal schema:
55
+ ```bash
56
+ MNEME_DIR=".mneme"
57
+
58
+ sqlite3 "$MNEME_DIR/local.db" "
59
+ CREATE TABLE IF NOT EXISTS interactions (
60
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
61
+ session_id TEXT NOT NULL,
62
+ project_path TEXT NOT NULL,
63
+ repository TEXT,
64
+ repository_url TEXT,
65
+ repository_root TEXT,
66
+ owner TEXT NOT NULL,
67
+ role TEXT NOT NULL,
68
+ content TEXT NOT NULL,
69
+ thinking TEXT,
70
+ tool_calls TEXT,
71
+ timestamp TEXT NOT NULL,
72
+ is_compact_summary INTEGER DEFAULT 0,
73
+ created_at TEXT DEFAULT (datetime('now'))
74
+ );
75
+ CREATE INDEX IF NOT EXISTS idx_interactions_session ON interactions(session_id);
76
+ CREATE INDEX IF NOT EXISTS idx_interactions_owner ON interactions(owner);
77
+ CREATE INDEX IF NOT EXISTS idx_interactions_project ON interactions(project_path);
78
+ CREATE INDEX IF NOT EXISTS idx_interactions_repo ON interactions(repository);
79
+
80
+ CREATE TABLE IF NOT EXISTS pre_compact_backups (
81
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
82
+ session_id TEXT NOT NULL,
83
+ project_path TEXT NOT NULL,
84
+ owner TEXT NOT NULL,
85
+ interactions TEXT NOT NULL,
86
+ created_at TEXT DEFAULT (datetime('now'))
87
+ );
88
+ CREATE INDEX IF NOT EXISTS idx_backups_session ON pre_compact_backups(session_id);
89
+ CREATE INDEX IF NOT EXISTS idx_backups_project ON pre_compact_backups(project_path);
90
+
91
+ CREATE TABLE IF NOT EXISTS migrations (
92
+ project_path TEXT PRIMARY KEY,
93
+ migrated_at TEXT DEFAULT (datetime('now'))
94
+ );
95
+ "
96
+ ```
97
+
98
+ **Note:** The local database stores interactions for this project only. It is gitignored to keep conversations private.
99
+
100
+ After creation, confirm success and explain that mneme will now track sessions in this project.
101
+ </instructions>