memory-journal-mcp 4.4.2 → 4.5.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.
- package/.github/workflows/lint-and-test.yml +1 -1
- package/.github/workflows/security-update.yml +1 -1
- package/CHANGELOG.md +81 -1
- package/DOCKER_README.md +57 -7
- package/Dockerfile +17 -17
- package/README.md +65 -6
- package/SECURITY.md +27 -35
- package/dist/cli.js +10 -0
- package/dist/cli.js.map +1 -1
- package/dist/constants/ServerInstructions.d.ts +5 -1
- package/dist/constants/ServerInstructions.d.ts.map +1 -1
- package/dist/constants/ServerInstructions.js +137 -83
- package/dist/constants/ServerInstructions.js.map +1 -1
- package/dist/database/SqliteAdapter.d.ts +2 -1
- package/dist/database/SqliteAdapter.d.ts.map +1 -1
- package/dist/database/SqliteAdapter.js +15 -8
- package/dist/database/SqliteAdapter.js.map +1 -1
- package/dist/handlers/resources/index.d.ts +3 -1
- package/dist/handlers/resources/index.d.ts.map +1 -1
- package/dist/handlers/resources/index.js +5 -2
- package/dist/handlers/resources/index.js.map +1 -1
- package/dist/handlers/tools/index.d.ts.map +1 -1
- package/dist/handlers/tools/index.js +63 -16
- package/dist/handlers/tools/index.js.map +1 -1
- package/dist/server/McpServer.d.ts +2 -0
- package/dist/server/McpServer.d.ts.map +1 -1
- package/dist/server/McpServer.js +43 -2
- package/dist/server/McpServer.js.map +1 -1
- package/dist/server/Scheduler.d.ts +91 -0
- package/dist/server/Scheduler.d.ts.map +1 -0
- package/dist/server/Scheduler.js +201 -0
- package/dist/server/Scheduler.js.map +1 -0
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +6 -3
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/security-utils.d.ts +0 -21
- package/dist/utils/security-utils.d.ts.map +1 -1
- package/dist/utils/security-utils.js +0 -47
- package/dist/utils/security-utils.js.map +1 -1
- package/hooks/README.md +107 -0
- package/hooks/cursor/hooks.json +10 -0
- package/hooks/cursor/memory-journal.mdc +22 -0
- package/hooks/cursor/session-end.sh +19 -0
- package/hooks/kilo-code/session-end-mode.json +11 -0
- package/hooks/kiro/session-end.md +13 -0
- package/package.json +8 -8
- package/releases/v4.5.0.md +116 -0
- package/scripts/generate-server-instructions.ts +176 -0
- package/scripts/server-instructions-function-body.ts +77 -0
- package/server.json +3 -3
- package/src/cli.ts +26 -0
- package/src/constants/ServerInstructions.ts +137 -83
- package/src/constants/server-instructions.md +262 -0
- package/src/database/SqliteAdapter.ts +22 -8
- package/src/handlers/resources/index.ts +8 -2
- package/src/handlers/tools/index.ts +70 -20
- package/src/server/McpServer.ts +60 -2
- package/src/server/Scheduler.ts +278 -0
- package/src/utils/logger.ts +6 -3
- package/src/utils/security-utils.ts +0 -52
- package/tests/constants/server-instructions.test.ts +26 -0
- package/tests/database/sqlite-adapter.test.ts +84 -0
- package/tests/filtering/tool-filter.test.ts +46 -0
- package/tests/handlers/github-resource-handlers.test.ts +453 -0
- package/tests/handlers/github-tool-handlers.test.ts +899 -0
- package/tests/handlers/prompt-handlers.test.ts +40 -0
- package/tests/handlers/resource-handlers.test.ts +32 -0
- package/tests/handlers/tool-handlers.test.ts +13 -2
- package/tests/security/sql-injection.test.ts +3 -54
- package/tests/server/mcp-server.test.ts +491 -5
- package/tests/server/scheduler.test.ts +400 -0
- package/tests/vector/vector-search-manager.test.ts +60 -0
- package/.vscode/settings.json +0 -84
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Server instructions for Memory Journal MCP.
|
|
3
3
|
*
|
|
4
|
+
* ⚠️ AUTO-GENERATED — DO NOT EDIT THIS FILE DIRECTLY
|
|
5
|
+
* Edit src/constants/server-instructions.md instead,
|
|
6
|
+
* then run: npm run generate:instructions
|
|
7
|
+
*
|
|
4
8
|
* These instructions are automatically sent to MCP clients during initialization,
|
|
5
9
|
* providing guidance for AI agents on tool usage.
|
|
6
10
|
*
|
|
7
|
-
*
|
|
11
|
+
* Optimized for token efficiency with tiered instruction levels.
|
|
8
12
|
*/
|
|
9
13
|
import { TOOL_GROUPS } from '../filtering/ToolFilter.js';
|
|
10
14
|
/**
|
|
@@ -14,29 +18,55 @@ import { TOOL_GROUPS } from '../filtering/ToolFilter.js';
|
|
|
14
18
|
const ESSENTIAL_INSTRUCTIONS = `# memory-journal-mcp
|
|
15
19
|
|
|
16
20
|
## Session Start
|
|
21
|
+
|
|
17
22
|
1. Read \`memory://briefing\` for project context
|
|
23
|
+
- In Cursor, use \`FetchMcpResource(server: "user-memory-journal-mcp", uri: "memory://briefing")\`
|
|
18
24
|
2. **Show the \`userMessage\` to the user** (it contains a formatted summary of project context)
|
|
19
25
|
3. Proceed with the user's request
|
|
20
26
|
|
|
21
27
|
## Behaviors
|
|
28
|
+
|
|
22
29
|
- **Create entries for**: implementations, decisions, bug fixes, milestones, user requests to "remember"
|
|
23
30
|
- **Search before**: major decisions, referencing prior work, understanding project context
|
|
24
31
|
- **Link entries**: implementation→spec, bugfix→issue, followup→prior work
|
|
25
32
|
|
|
33
|
+
## Session End
|
|
34
|
+
|
|
35
|
+
When a conversation or task is wrapping up (user says "thanks," final deliverable complete, no more work planned):
|
|
36
|
+
|
|
37
|
+
1. Create a journal entry summarizing the session:
|
|
38
|
+
- **What was accomplished** (key changes, decisions, files modified)
|
|
39
|
+
- **What's unfinished or blocked** (pending items, open questions)
|
|
40
|
+
- **Context for next session** (relevant entry IDs, branch names, PR numbers)
|
|
41
|
+
2. Use \`entry_type: "retrospective"\` and tag with \`session-summary\`
|
|
42
|
+
3. This is opt-out — ALWAYS create the entry, even for short/trivial sessions, unless the user explicitly says to skip it
|
|
43
|
+
|
|
44
|
+
> If your client has hooks configured for session-end journaling (e.g., Cursor \`sessionEnd\` hook), this is handled automatically. Otherwise, follow the steps above.
|
|
45
|
+
|
|
46
|
+
## Rule & Skill Suggestions
|
|
47
|
+
|
|
48
|
+
When you notice the user consistently applies patterns, preferences, or workflows that could be codified:
|
|
49
|
+
|
|
50
|
+
- **Offer to create a rule or skill** — always ask the user first, never create silently
|
|
51
|
+
- Examples: coding conventions, testing patterns, deployment steps, project-specific commands
|
|
52
|
+
- Frame it as: "I noticed you always [pattern]. Would you like me to save this as a rule/skill so future agents follow it automatically?"
|
|
53
|
+
|
|
26
54
|
## Quick Access
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
|
30
|
-
|
|
|
31
|
-
|
|
|
32
|
-
|
|
|
33
|
-
|
|
|
55
|
+
|
|
56
|
+
| Purpose | Action |
|
|
57
|
+
| --------------- | --------------------------- |
|
|
58
|
+
| Session context | \`memory://briefing\` |
|
|
59
|
+
| Recent entries | \`memory://recent\` |
|
|
60
|
+
| Health/time | \`memory://health\` |
|
|
61
|
+
| Semantic search | \`semantic_search(query)\` |
|
|
62
|
+
| Full context | \`get-context-bundle\` prompt |
|
|
34
63
|
`;
|
|
35
64
|
/**
|
|
36
65
|
* GitHub integration patterns (~150 additional tokens)
|
|
37
66
|
*/
|
|
38
67
|
const GITHUB_INSTRUCTIONS = `
|
|
39
68
|
## GitHub Integration
|
|
69
|
+
|
|
40
70
|
- Include \`issue_number\`/\`pr_number\` in \`create_entry\` to auto-link
|
|
41
71
|
- After closing issue/merging PR → create summary entry with learnings
|
|
42
72
|
- CI failures → \`actions-failure-digest\` prompt or \`memory://actions/recent\`
|
|
@@ -51,26 +81,34 @@ const SERVER_ACCESS_INSTRUCTIONS = `
|
|
|
51
81
|
## How to Access This Server
|
|
52
82
|
|
|
53
83
|
### Calling Tools
|
|
84
|
+
|
|
54
85
|
Use \`CallMcpTool\` with server name \`user-memory-journal-mcp\`:
|
|
86
|
+
|
|
55
87
|
\`\`\`
|
|
56
88
|
CallMcpTool(server: "user-memory-journal-mcp", toolName: "create_entry", arguments: {...})
|
|
57
89
|
\`\`\`
|
|
58
90
|
|
|
59
91
|
### Listing Resources
|
|
92
|
+
|
|
60
93
|
Use \`ListMcpResources\` with server name:
|
|
94
|
+
|
|
61
95
|
\`\`\`
|
|
62
96
|
ListMcpResources(server: "user-memory-journal-mcp")
|
|
63
97
|
\`\`\`
|
|
98
|
+
|
|
64
99
|
Do NOT try to browse filesystem paths for MCP tool/resource definitions - use the MCP protocol directly.
|
|
65
100
|
|
|
66
101
|
### Fetching Resources
|
|
102
|
+
|
|
67
103
|
Use \`FetchMcpResource\` with server name and \`memory://\` URI:
|
|
104
|
+
|
|
68
105
|
\`\`\`
|
|
69
106
|
FetchMcpResource(server: "user-memory-journal-mcp", uri: "memory://recent")
|
|
70
107
|
FetchMcpResource(server: "user-memory-journal-mcp", uri: "memory://kanban/1")
|
|
71
108
|
\`\`\`
|
|
72
109
|
|
|
73
110
|
## Quick Health Check
|
|
111
|
+
|
|
74
112
|
Fetch \`memory://health\` to verify server status, database stats, and tool availability.
|
|
75
113
|
`;
|
|
76
114
|
/**
|
|
@@ -80,57 +118,64 @@ const TOOL_PARAMETER_REFERENCE = `
|
|
|
80
118
|
## Tool Parameter Reference
|
|
81
119
|
|
|
82
120
|
### Entry Operations
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
|
86
|
-
| \`
|
|
87
|
-
| \`
|
|
88
|
-
| \`
|
|
89
|
-
| \`
|
|
90
|
-
| \`
|
|
91
|
-
| \`
|
|
121
|
+
|
|
122
|
+
| Tool | Required Parameters | Optional Parameters |
|
|
123
|
+
| ---------------------- | ------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
124
|
+
| \`create_entry\` | \`content\` (string) | \`entry_type\`, \`tags\` (array), \`is_personal\`, \`significance_type\`, \`share_with_team\`, \`auto_context\`, \`issue_number\`, \`issue_url\`, \`pr_number\`, \`pr_url\`, \`pr_status\`, \`project_number\`, \`project_owner\`, \`workflow_run_id\`, \`workflow_name\`, \`workflow_status\` |
|
|
125
|
+
| \`create_entry_minimal\` | \`content\` (string) | none |
|
|
126
|
+
| \`get_entry_by_id\` | \`entry_id\` (number) | \`include_relationships\` (bool, default true) |
|
|
127
|
+
| \`get_recent_entries\` | none | \`limit\` (default 5), \`is_personal\` (bool) |
|
|
128
|
+
| \`update_entry\` | \`entry_id\` (number) | \`content\`, \`tags\`, \`entry_type\`, \`is_personal\` |
|
|
129
|
+
| \`delete_entry\` | \`entry_id\` (number) | \`permanent\` (bool, default false) |
|
|
130
|
+
| \`list_tags\` | none | none |
|
|
92
131
|
|
|
93
132
|
### Search Tools
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
|
97
|
-
| \`
|
|
98
|
-
| \`
|
|
99
|
-
| \`
|
|
133
|
+
|
|
134
|
+
| Tool | Required Parameters | Optional Parameters |
|
|
135
|
+
| ------------------------ | ------------------------------------- | -------------------------------------------------------------------------------------------------------------- |
|
|
136
|
+
| \`search_entries\` | none | \`query\`, \`limit\`, \`is_personal\`, \`issue_number\`, \`pr_number\`, \`pr_status\`, \`project_number\`, \`workflow_run_id\` |
|
|
137
|
+
| \`search_by_date_range\` | \`start_date\`, \`end_date\` (YYYY-MM-DD) | \`tags\`, \`entry_type\`, \`is_personal\`, \`issue_number\`, \`pr_number\`, \`project_number\`, \`workflow_run_id\` |
|
|
138
|
+
| \`semantic_search\` | \`query\` (string) | \`limit\`, \`similarity_threshold\` (default 0.25), \`is_personal\`, \`hint_on_empty\` (bool, default true) |
|
|
139
|
+
| \`get_vector_index_stats\` | none | none |
|
|
100
140
|
|
|
101
141
|
### Relationship Tools
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
|
105
|
-
| \`
|
|
142
|
+
|
|
143
|
+
| Tool | Required Parameters | Notes |
|
|
144
|
+
| ------------------------- | ---------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
145
|
+
| \`link_entries\` | \`from_entry_id\`, \`to_entry_id\` (numbers) | Types: \`evolves_from\`, \`references\`, \`implements\`, \`clarifies\`, \`response_to\`, \`blocked_by\`, \`resolved\`, \`caused\`. Optional \`description\`. |
|
|
146
|
+
| \`visualize_relationships\` | none | Optional \`entry_id\`, \`tags\` (array), \`depth\` (1-3, default 2), \`limit\` (default 20). Returns Mermaid diagram. |
|
|
106
147
|
|
|
107
148
|
### GitHub Tools
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
|
111
|
-
| \`
|
|
112
|
-
| \`
|
|
113
|
-
| \`
|
|
114
|
-
| \`
|
|
115
|
-
| \`
|
|
149
|
+
|
|
150
|
+
| Tool | Required Parameters | Notes |
|
|
151
|
+
| -------------------- | ----------------------- | ---------------------------------------------------------------------------------------------------------------------------- |
|
|
152
|
+
| \`get_github_context\` | none | Returns repo info, open issues/PRs. Only counts OPEN items. |
|
|
153
|
+
| \`get_github_issues\` | none | Optional \`state\` (open/closed/all), \`limit\`, \`owner\`, \`repo\` |
|
|
154
|
+
| \`get_github_prs\` | none | Optional \`state\`, \`limit\`, \`owner\`, \`repo\` |
|
|
155
|
+
| \`get_github_issue\` | \`issue_number\` (number) | Optional \`owner\`, \`repo\`. Fetches single issue details. |
|
|
156
|
+
| \`get_github_pr\` | \`pr_number\` (number) | Optional \`owner\`, \`repo\`. Fetches single PR details. |
|
|
157
|
+
| \`get_repo_insights\` | none | Optional \`sections\` (stars/traffic/referrers/paths/all, default "stars"), \`owner\`, \`repo\`. Requires push access for traffic. |
|
|
116
158
|
|
|
117
159
|
GitHub tools auto-detect owner/repo from GITHUB_REPO_PATH. If \`detectedOwner\`/\`detectedRepo\` are null in response, specify \`owner\` and \`repo\` parameters explicitly.
|
|
118
160
|
|
|
119
161
|
### Issue Lifecycle Tools
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
|
123
|
-
| \`
|
|
162
|
+
|
|
163
|
+
| Tool | Required Parameters | Notes |
|
|
164
|
+
| -------------------------------- | ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
165
|
+
| \`create_github_issue_with_entry\` | \`title\` (string) | Optional \`body\`, \`labels\` (array), \`assignees\` (array), \`project_number\`, \`initial_status\`, \`milestone_number\`, \`entry_content\`, \`tags\`, \`owner\`, \`repo\` |
|
|
166
|
+
| \`close_github_issue_with_entry\` | \`issue_number\` (number) | Optional \`comment\`, \`resolution_notes\`, \`tags\`, \`move_to_done\` (bool), \`project_number\`, \`owner\`, \`repo\` |
|
|
124
167
|
|
|
125
168
|
### Kanban Tools (GitHub Projects v2)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
|
169
|
+
|
|
170
|
+
| Tool | Required Parameters | Notes |
|
|
171
|
+
| ------------------ | -------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
172
|
+
| \`get_kanban_board\` | \`project_number\` (number) | Optional \`owner\`. Returns columns with items grouped by Status |
|
|
129
173
|
| \`move_kanban_item\` | \`project_number\`, \`item_id\` (string), \`target_status\` (string) | Optional \`owner\`. \`item_id\` is the GraphQL node ID from board items. Status matching is case-insensitive. |
|
|
130
174
|
|
|
131
175
|
**Finding the right project**: User may have multiple projects. Use \`get_kanban_board\` with different project numbers (1, 2, 3...) to find the correct one by checking \`projectTitle\`.
|
|
132
176
|
|
|
133
177
|
**Default Status columns** (typical GitHub Projects v2):
|
|
178
|
+
|
|
134
179
|
- \`Backlog\` - Items not yet started
|
|
135
180
|
- \`Ready\` - Ready to be picked up
|
|
136
181
|
- \`In progress\` - Actively being worked on
|
|
@@ -140,39 +185,46 @@ GitHub tools auto-detect owner/repo from GITHUB_REPO_PATH. If \`detectedOwner\`/
|
|
|
140
185
|
Note: Status columns are dynamic per project. The \`statusOptions\` in the response shows available statuses for that specific project.
|
|
141
186
|
|
|
142
187
|
Kanban resources:
|
|
188
|
+
|
|
143
189
|
- \`memory://kanban/{project_number}\` - JSON board data
|
|
144
190
|
- \`memory://kanban/{project_number}/diagram\` - Mermaid visualization
|
|
145
191
|
|
|
146
192
|
### Milestone Tools
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
|
150
|
-
| \`
|
|
151
|
-
| \`
|
|
152
|
-
| \`
|
|
153
|
-
| \`
|
|
193
|
+
|
|
194
|
+
| Tool | Required Parameters | Notes |
|
|
195
|
+
| ------------------------- | ----------------------------------- | --------------------------------------------------------------------------------- |
|
|
196
|
+
| \`get_github_milestones\` | none | Optional \`state\` (open/closed/all), \`limit\`, \`owner\`, \`repo\` |
|
|
197
|
+
| \`get_github_milestone\` | \`milestone_number\` (number) | Optional \`owner\`, \`repo\`. Single milestone with completion %. |
|
|
198
|
+
| \`create_github_milestone\` | \`title\` (string) | Optional \`description\`, \`due_on\` (YYYY-MM-DD), \`owner\`, \`repo\` |
|
|
199
|
+
| \`update_github_milestone\` | \`milestone_number\` (number) | Optional \`title\`, \`description\`, \`due_on\`, \`state\` (open/closed), \`owner\`, \`repo\` |
|
|
200
|
+
| \`delete_github_milestone\` | \`milestone_number\`, \`confirm: true\` | Optional \`owner\`, \`repo\`. Permanent deletion. |
|
|
154
201
|
|
|
155
202
|
Milestone resources:
|
|
203
|
+
|
|
156
204
|
- \`memory://github/milestones\` - Open milestones with completion %
|
|
157
205
|
- \`memory://milestones/{number}\` - Single milestone detail
|
|
158
206
|
|
|
159
207
|
### Admin Tools
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
|
163
|
-
| \`
|
|
164
|
-
| \`
|
|
165
|
-
| \`
|
|
166
|
-
| \`
|
|
167
|
-
| \`
|
|
208
|
+
|
|
209
|
+
| Tool | Required Parameters | Notes |
|
|
210
|
+
| ---------------------- | --------------------------- | ---------------------------------------------------------------------------- |
|
|
211
|
+
| \`backup_journal\` | none | Optional \`name\` (custom backup name) |
|
|
212
|
+
| \`list_backups\` | none | Returns available backup files |
|
|
213
|
+
| \`cleanup_backups\` | none | Optional \`keep_count\` (default 5). Deletes old backups, keeps N most recent. |
|
|
214
|
+
| \`restore_backup\` | \`filename\`, \`confirm: true\` | Creates auto-backup before restore |
|
|
215
|
+
| \`add_to_vector_index\` | \`entry_id\` (single number) | Indexes one entry for semantic search |
|
|
216
|
+
| \`rebuild_vector_index\` | none | Re-indexes all entries |
|
|
168
217
|
|
|
169
218
|
### Export Tools
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
|
219
|
+
|
|
220
|
+
| Tool | Required Parameters | Notes |
|
|
221
|
+
| ---------------- | ------------------- | --------------------------------------------------------------------------------------------------------- |
|
|
222
|
+
| \`export_entries\` | none | Optional \`format\` (json/markdown), \`limit\` (default 100), \`tags\`, \`start_date\`, \`end_date\`, \`entry_types\` |
|
|
173
223
|
|
|
174
224
|
## Entry Types
|
|
225
|
+
|
|
175
226
|
Valid values for \`entry_type\` parameter:
|
|
227
|
+
|
|
176
228
|
- \`personal_reflection\` (default) - Personal thoughts and notes
|
|
177
229
|
- \`project_decision\` - Architectural and team decisions
|
|
178
230
|
- \`technical_achievement\` - Milestones and breakthroughs
|
|
@@ -188,6 +240,7 @@ Valid values for \`entry_type\` parameter:
|
|
|
188
240
|
- \`other\` - Miscellaneous
|
|
189
241
|
|
|
190
242
|
## Field Notes
|
|
243
|
+
|
|
191
244
|
- **\`autoContext\`**: Reserved for future automatic context capture. Currently always \`null\`.
|
|
192
245
|
- **\`memory://tags\` vs \`list_tags\`**: Resource includes \`id\`, \`name\`, \`count\`; tool returns only \`name\`, \`count\`. Neither returns orphan tags with zero usage.
|
|
193
246
|
- **Tag naming**: Use lowercase with dashes (e.g., \`bug-fix\`, \`phase-2\`). Use \`merge_tags\` to consolidate duplicates (e.g., merge \`phase2\` into \`phase-2\`).
|
|
@@ -204,29 +257,30 @@ Valid values for \`entry_type\` parameter:
|
|
|
204
257
|
- **\`delete_entry\` on soft-deleted**: \`delete_entry(id, permanent: true)\` works on previously soft-deleted entries. Returns \`success: false\` for nonexistent entries.
|
|
205
258
|
|
|
206
259
|
## Key Resources
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
|
210
|
-
| \`memory://
|
|
211
|
-
| \`memory://
|
|
212
|
-
| \`memory://
|
|
213
|
-
| \`memory://
|
|
214
|
-
| \`memory://
|
|
215
|
-
| \`memory://
|
|
216
|
-
| \`memory://
|
|
217
|
-
| \`memory://graph/
|
|
218
|
-
| \`memory://actions
|
|
219
|
-
| \`memory://
|
|
220
|
-
| \`memory://
|
|
221
|
-
| \`memory://github/
|
|
222
|
-
| \`memory://github/
|
|
223
|
-
| \`memory://
|
|
224
|
-
| \`memory://kanban/{n}
|
|
225
|
-
| \`memory://
|
|
226
|
-
| \`memory://
|
|
227
|
-
| \`memory://
|
|
228
|
-
| \`memory://
|
|
229
|
-
| \`memory://prs/{n}/
|
|
260
|
+
|
|
261
|
+
| URI | Description |
|
|
262
|
+
| -------------------------------- | -------------------------------------------------- |
|
|
263
|
+
| \`memory://health\` | Server health, DB stats, tool filter status |
|
|
264
|
+
| \`memory://briefing\` | Session context with userMessage to show user |
|
|
265
|
+
| \`memory://instructions\` | Full server instructions and tool reference |
|
|
266
|
+
| \`memory://statistics\` | Entry counts by type and period |
|
|
267
|
+
| \`memory://recent\` | 10 most recent entries |
|
|
268
|
+
| \`memory://tags\` | All tags with usage counts |
|
|
269
|
+
| \`memory://significant\` | Entries sorted by importance score |
|
|
270
|
+
| \`memory://graph/recent\` | Mermaid diagram of recent relationships |
|
|
271
|
+
| \`memory://graph/actions\` | CI/CD narrative graph |
|
|
272
|
+
| \`memory://actions/recent\` | Recent workflow runs |
|
|
273
|
+
| \`memory://team/recent\` | Team-shared entries |
|
|
274
|
+
| \`memory://github/status\` | GitHub repo overview (CI, issues, PRs, milestones) |
|
|
275
|
+
| \`memory://github/milestones\` | Open milestones with completion % |
|
|
276
|
+
| \`memory://github/insights\` | Stars, forks, and 14-day traffic summary |
|
|
277
|
+
| \`memory://kanban/{n}\` | Kanban board for project number n |
|
|
278
|
+
| \`memory://kanban/{n}/diagram\` | Mermaid Kanban visualization |
|
|
279
|
+
| \`memory://milestones/{n}\` | Single milestone detail + progress |
|
|
280
|
+
| \`memory://projects/{n}/timeline\` | Project entries timeline |
|
|
281
|
+
| \`memory://issues/{n}/entries\` | Entries linked to issue n |
|
|
282
|
+
| \`memory://prs/{n}/entries\` | Entries linked to PR n |
|
|
283
|
+
| \`memory://prs/{n}/timeline\` | PR lifecycle and linked entries |
|
|
230
284
|
`;
|
|
231
285
|
/**
|
|
232
286
|
* Generate dynamic instructions based on enabled tools, resources, prompts, and latest entry
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServerInstructions.js","sourceRoot":"","sources":["../../src/constants/ServerInstructions.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ServerInstructions.js","sourceRoot":"","sources":["../../src/constants/ServerInstructions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AAqCxD;;;GAGG;AACH,MAAM,sBAAsB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6C9B,CAAA;AAED;;GAEG;AACH,MAAM,mBAAmB,GAAG;;;;;;;;;CAS3B,CAAA;AAED;;GAEG;AACH,MAAM,0BAA0B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiClC,CAAA;AAED;;GAEG;AACH,MAAM,wBAAwB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuKhC,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,oBAAoB,CAChC,YAAyB,EACzB,UAAgC,EAChC,OAA2B,EAC3B,WAAiC,EACjC,QAA0B,UAAU;IAEpC,IAAI,YAAY,GAAG,sBAAsB,CAAA;IAEzC,mEAAmE;IACnE,IAAI,WAAW,EAAE,CAAC;QACd,MAAM,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAA;QACjD,YAAY,IAAI,kBAAkB,MAAM,C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YAC1E,CAAC;QACL,CAAC;IACL,CAAC;IAED,OAAO,YAAY,CAAA;AACvB,CAAC;AAED;;GAEG;AACH,SAAS,mBAAmB,CAAC,YAAyB;IAClD,MAAM,YAAY,GAA4C,EAAE,CAAA;IAEhE,KAAK,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAA4B,EAAE,CAAC;QACrF,MAAM,cAAc,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,YAAY,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAA;QACxE,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC5B,YAAY,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC,CAAA;QACvD,CAAC;IACL,CAAC;IAED,OAAO,YAAY,CAAA;AACvB,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,sBAAsB,GAAG,mBAAmB,CAAA"}
|
|
@@ -279,7 +279,8 @@ export declare class SqliteAdapter {
|
|
|
279
279
|
*/
|
|
280
280
|
private rowToEntry;
|
|
281
281
|
/**
|
|
282
|
-
* Get raw
|
|
282
|
+
* Get raw sql.js Database handle for advanced queries.
|
|
283
|
+
* @internal Callers MUST use parameterized queries — never concatenate user input into SQL.
|
|
283
284
|
*/
|
|
284
285
|
getRawDb(): Database;
|
|
285
286
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SqliteAdapter.d.ts","sourceRoot":"","sources":["../../src/database/SqliteAdapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAkB,EAAE,KAAK,QAAQ,EAAE,MAAM,QAAQ,CAAA;
|
|
1
|
+
{"version":3,"file":"SqliteAdapter.d.ts","sourceRoot":"","sources":["../../src/database/SqliteAdapter.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAA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zB,QAAQ,EAAE,MAAM,CAAA;SACnB,CAAA;QACD,OAAO,EAAE;YACL,SAAS,EAAE,MAAM,CAAA;YACjB,KAAK,EAAE,MAAM,CAAA;YACb,UAAU,EAAE;gBAAE,QAAQ,EAAE,MAAM,CAAC;gBAAC,SAAS,EAAE,MAAM,CAAC;gBAAC,SAAS,EAAE,MAAM,CAAA;aAAE,GAAG,IAAI,CAAA;SAChF,CAAA;KACJ;IAwDD;;OAEG;IACH,OAAO,CAAC,WAAW;IAQnB;;OAEG;IACH,OAAO,CAAC,UAAU;IA0BlB;;;OAGG;IACH,QAAQ,IAAI,QAAQ;CAGvB"}
|
|
@@ -8,7 +8,7 @@ import initSqlJs from 'sql.js';
|
|
|
8
8
|
import * as fs from 'node:fs';
|
|
9
9
|
import * as path from 'node:path';
|
|
10
10
|
import { logger } from '../utils/logger.js';
|
|
11
|
-
import { validateDateFormatPattern } from '../utils/security-utils.js';
|
|
11
|
+
import { validateDateFormatPattern, sanitizeSearchQuery, assertNoPathTraversal, } from '../utils/security-utils.js';
|
|
12
12
|
// Schema SQL for initialization
|
|
13
13
|
const SCHEMA_SQL = `
|
|
14
14
|
-- Main journal entries table
|
|
@@ -128,6 +128,9 @@ export class SqliteAdapter {
|
|
|
128
128
|
}
|
|
129
129
|
// Initialize schema
|
|
130
130
|
this.db.run(SCHEMA_SQL);
|
|
131
|
+
// Enable foreign key enforcement (SQLite disables by default)
|
|
132
|
+
// Required for ON DELETE CASCADE in entry_tags, relationships, embeddings
|
|
133
|
+
this.db.run('PRAGMA foreign_keys = ON');
|
|
131
134
|
this.initialized = true;
|
|
132
135
|
logger.info('Database opened', { module: 'SqliteAdapter', dbPath: this.dbPath });
|
|
133
136
|
// Immediate flush after initialization to persist schema
|
|
@@ -438,9 +441,9 @@ export class SqliteAdapter {
|
|
|
438
441
|
const { limit = 10, isPersonal, projectNumber, issueNumber, prNumber } = options;
|
|
439
442
|
let sql = `
|
|
440
443
|
SELECT * FROM memory_journal
|
|
441
|
-
WHERE deleted_at IS NULL AND content LIKE ?
|
|
444
|
+
WHERE deleted_at IS NULL AND content LIKE ? ESCAPE '\\'
|
|
442
445
|
`;
|
|
443
|
-
const params = [`%${query}%`];
|
|
446
|
+
const params = [`%${sanitizeSearchQuery(query)}%`];
|
|
444
447
|
if (isPersonal !== undefined) {
|
|
445
448
|
sql += ` AND is_personal = ?`;
|
|
446
449
|
params.push(isPersonal ? 1 : 0);
|
|
@@ -786,6 +789,10 @@ export class SqliteAdapter {
|
|
|
786
789
|
exportToFile(backupName) {
|
|
787
790
|
const db = this.ensureDb();
|
|
788
791
|
const backupsDir = this.getBackupsDir();
|
|
792
|
+
// Validate backup name against path traversal before sanitization
|
|
793
|
+
if (backupName) {
|
|
794
|
+
assertNoPathTraversal(backupName);
|
|
795
|
+
}
|
|
789
796
|
// Ensure backups directory exists
|
|
790
797
|
if (!fs.existsSync(backupsDir)) {
|
|
791
798
|
fs.mkdirSync(backupsDir, { recursive: true });
|
|
@@ -854,7 +861,7 @@ export class SqliteAdapter {
|
|
|
854
861
|
*/
|
|
855
862
|
deleteOldBackups(keepCount) {
|
|
856
863
|
const backups = this.listBackups(); // Already sorted newest-first
|
|
857
|
-
if (keepCount < 1) {
|
|
864
|
+
if (keepCount < 1 || Number.isNaN(keepCount)) {
|
|
858
865
|
throw new Error('keepCount must be at least 1');
|
|
859
866
|
}
|
|
860
867
|
const toKeep = backups.slice(0, keepCount);
|
|
@@ -883,9 +890,7 @@ export class SqliteAdapter {
|
|
|
883
890
|
*/
|
|
884
891
|
async restoreFromFile(filename) {
|
|
885
892
|
// Validate filename (prevent path traversal)
|
|
886
|
-
|
|
887
|
-
throw new Error('Invalid backup filename: path separators not allowed');
|
|
888
|
-
}
|
|
893
|
+
assertNoPathTraversal(filename);
|
|
889
894
|
const backupsDir = this.getBackupsDir();
|
|
890
895
|
const backupPath = path.join(backupsDir, filename);
|
|
891
896
|
if (!fs.existsSync(backupPath)) {
|
|
@@ -906,6 +911,7 @@ export class SqliteAdapter {
|
|
|
906
911
|
// Initialize new database from backup
|
|
907
912
|
const SQL = await import('sql.js').then((m) => m.default());
|
|
908
913
|
this.db = new SQL.Database(backupBuffer);
|
|
914
|
+
this.db.run('PRAGMA foreign_keys = ON');
|
|
909
915
|
this.initialized = true;
|
|
910
916
|
// Get new entry count
|
|
911
917
|
const newCountResult = this.db.exec('SELECT COUNT(*) FROM memory_journal WHERE deleted_at IS NULL');
|
|
@@ -1016,7 +1022,8 @@ export class SqliteAdapter {
|
|
|
1016
1022
|
};
|
|
1017
1023
|
}
|
|
1018
1024
|
/**
|
|
1019
|
-
* Get raw
|
|
1025
|
+
* Get raw sql.js Database handle for advanced queries.
|
|
1026
|
+
* @internal Callers MUST use parameterized queries — never concatenate user input into SQL.
|
|
1020
1027
|
*/
|
|
1021
1028
|
getRawDb() {
|
|
1022
1029
|
return this.ensureDb();
|