memory-journal-mcp 4.4.2 → 5.0.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/codeql.yml +1 -6
- package/.github/workflows/docker-publish.yml +15 -49
- package/.github/workflows/lint-and-test.yml +1 -1
- package/.github/workflows/secrets-scanning.yml +4 -3
- package/.github/workflows/security-update.yml +3 -3
- package/CHANGELOG.md +213 -0
- package/CONTRIBUTING.md +132 -97
- package/DOCKER_README.md +184 -235
- package/Dockerfile +27 -24
- package/README.md +218 -190
- package/SECURITY.md +27 -35
- package/dist/cli.js +16 -1
- 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 +133 -73
- package/dist/constants/ServerInstructions.js.map +1 -1
- package/dist/constants/icons.d.ts +2 -2
- package/dist/constants/icons.d.ts.map +1 -1
- package/dist/constants/icons.js +7 -6
- package/dist/constants/icons.js.map +1 -1
- package/dist/database/SqliteAdapter.d.ts +37 -24
- package/dist/database/SqliteAdapter.d.ts.map +1 -1
- package/dist/database/SqliteAdapter.js +319 -157
- package/dist/database/SqliteAdapter.js.map +1 -1
- package/dist/database/schema.d.ts +45 -0
- package/dist/database/schema.d.ts.map +1 -0
- package/dist/database/schema.js +92 -0
- package/dist/database/schema.js.map +1 -0
- package/dist/filtering/ToolFilter.d.ts +1 -1
- package/dist/filtering/ToolFilter.d.ts.map +1 -1
- package/dist/filtering/ToolFilter.js +13 -2
- package/dist/filtering/ToolFilter.js.map +1 -1
- package/dist/github/GitHubIntegration.d.ts.map +1 -1
- package/dist/github/GitHubIntegration.js +1 -3
- package/dist/github/GitHubIntegration.js.map +1 -1
- package/dist/handlers/prompts/github.d.ts +12 -0
- package/dist/handlers/prompts/github.d.ts.map +1 -0
- package/dist/handlers/prompts/github.js +178 -0
- package/dist/handlers/prompts/github.js.map +1 -0
- package/dist/handlers/prompts/index.d.ts +23 -2
- package/dist/handlers/prompts/index.d.ts.map +1 -1
- package/dist/handlers/prompts/index.js +7 -432
- package/dist/handlers/prompts/index.js.map +1 -1
- package/dist/handlers/prompts/workflow.d.ts +12 -0
- package/dist/handlers/prompts/workflow.d.ts.map +1 -0
- package/dist/handlers/prompts/workflow.js +277 -0
- package/dist/handlers/prompts/workflow.js.map +1 -0
- package/dist/handlers/resources/core.d.ts +11 -0
- package/dist/handlers/resources/core.d.ts.map +1 -0
- package/dist/handlers/resources/core.js +433 -0
- package/dist/handlers/resources/core.js.map +1 -0
- package/dist/handlers/resources/github.d.ts +11 -0
- package/dist/handlers/resources/github.d.ts.map +1 -0
- package/dist/handlers/resources/github.js +314 -0
- package/dist/handlers/resources/github.js.map +1 -0
- package/dist/handlers/resources/graph.d.ts +11 -0
- package/dist/handlers/resources/graph.d.ts.map +1 -0
- package/dist/handlers/resources/graph.js +204 -0
- package/dist/handlers/resources/graph.js.map +1 -0
- package/dist/handlers/resources/index.d.ts +5 -20
- package/dist/handlers/resources/index.d.ts.map +1 -1
- package/dist/handlers/resources/index.js +16 -1278
- package/dist/handlers/resources/index.js.map +1 -1
- package/dist/handlers/resources/shared.d.ts +60 -0
- package/dist/handlers/resources/shared.d.ts.map +1 -0
- package/dist/handlers/resources/shared.js +49 -0
- package/dist/handlers/resources/shared.js.map +1 -0
- package/dist/handlers/resources/team.d.ts +13 -0
- package/dist/handlers/resources/team.d.ts.map +1 -0
- package/dist/handlers/resources/team.js +119 -0
- package/dist/handlers/resources/team.js.map +1 -0
- package/dist/handlers/resources/templates.d.ts +13 -0
- package/dist/handlers/resources/templates.d.ts.map +1 -0
- package/dist/handlers/resources/templates.js +310 -0
- package/dist/handlers/resources/templates.js.map +1 -0
- package/dist/handlers/tools/admin.d.ts +8 -0
- package/dist/handlers/tools/admin.d.ts.map +1 -0
- package/dist/handlers/tools/admin.js +270 -0
- package/dist/handlers/tools/admin.js.map +1 -0
- package/dist/handlers/tools/analytics.d.ts +8 -0
- package/dist/handlers/tools/analytics.d.ts.map +1 -0
- package/dist/handlers/tools/analytics.js +256 -0
- package/dist/handlers/tools/analytics.js.map +1 -0
- package/dist/handlers/tools/backup.d.ts +8 -0
- package/dist/handlers/tools/backup.d.ts.map +1 -0
- package/dist/handlers/tools/backup.js +224 -0
- package/dist/handlers/tools/backup.js.map +1 -0
- package/dist/handlers/tools/core.d.ts +9 -0
- package/dist/handlers/tools/core.d.ts.map +1 -0
- package/dist/handlers/tools/core.js +326 -0
- package/dist/handlers/tools/core.js.map +1 -0
- package/dist/handlers/tools/export.d.ts +8 -0
- package/dist/handlers/tools/export.d.ts.map +1 -0
- package/dist/handlers/tools/export.js +89 -0
- package/dist/handlers/tools/export.js.map +1 -0
- package/dist/handlers/tools/github/helpers.d.ts +34 -0
- package/dist/handlers/tools/github/helpers.d.ts.map +1 -0
- package/dist/handlers/tools/github/helpers.js +52 -0
- package/dist/handlers/tools/github/helpers.js.map +1 -0
- package/dist/handlers/tools/github/insights-tools.d.ts +8 -0
- package/dist/handlers/tools/github/insights-tools.d.ts.map +1 -0
- package/dist/handlers/tools/github/insights-tools.js +104 -0
- package/dist/handlers/tools/github/insights-tools.js.map +1 -0
- package/dist/handlers/tools/github/issue-tools.d.ts +8 -0
- package/dist/handlers/tools/github/issue-tools.d.ts.map +1 -0
- package/dist/handlers/tools/github/issue-tools.js +359 -0
- package/dist/handlers/tools/github/issue-tools.js.map +1 -0
- package/dist/handlers/tools/github/kanban-tools.d.ts +8 -0
- package/dist/handlers/tools/github/kanban-tools.d.ts.map +1 -0
- package/dist/handlers/tools/github/kanban-tools.js +108 -0
- package/dist/handlers/tools/github/kanban-tools.js.map +1 -0
- package/dist/handlers/tools/github/milestone-tools.d.ts +9 -0
- package/dist/handlers/tools/github/milestone-tools.d.ts.map +1 -0
- package/dist/handlers/tools/github/milestone-tools.js +302 -0
- package/dist/handlers/tools/github/milestone-tools.js.map +1 -0
- package/dist/handlers/tools/github/mutation-tools.d.ts +12 -0
- package/dist/handlers/tools/github/mutation-tools.d.ts.map +1 -0
- package/dist/handlers/tools/github/mutation-tools.js +15 -0
- package/dist/handlers/tools/github/mutation-tools.js.map +1 -0
- package/dist/handlers/tools/github/read-tools.d.ts +8 -0
- package/dist/handlers/tools/github/read-tools.d.ts.map +1 -0
- package/dist/handlers/tools/github/read-tools.js +260 -0
- package/dist/handlers/tools/github/read-tools.js.map +1 -0
- package/dist/handlers/tools/github/schemas.d.ts +467 -0
- package/dist/handlers/tools/github/schemas.d.ts.map +1 -0
- package/dist/handlers/tools/github/schemas.js +335 -0
- package/dist/handlers/tools/github/schemas.js.map +1 -0
- package/dist/handlers/tools/github.d.ts +14 -0
- package/dist/handlers/tools/github.d.ts.map +1 -0
- package/dist/handlers/tools/github.js +28 -0
- package/dist/handlers/tools/github.js.map +1 -0
- package/dist/handlers/tools/index.d.ts +15 -20
- package/dist/handlers/tools/index.d.ts.map +1 -1
- package/dist/handlers/tools/index.js +117 -2909
- package/dist/handlers/tools/index.js.map +1 -1
- package/dist/handlers/tools/relationships.d.ts +8 -0
- package/dist/handlers/tools/relationships.d.ts.map +1 -0
- package/dist/handlers/tools/relationships.js +308 -0
- package/dist/handlers/tools/relationships.js.map +1 -0
- package/dist/handlers/tools/schemas.d.ts +108 -0
- package/dist/handlers/tools/schemas.d.ts.map +1 -0
- package/dist/handlers/tools/schemas.js +122 -0
- package/dist/handlers/tools/schemas.js.map +1 -0
- package/dist/handlers/tools/search.d.ts +8 -0
- package/dist/handlers/tools/search.d.ts.map +1 -0
- package/dist/handlers/tools/search.js +282 -0
- package/dist/handlers/tools/search.js.map +1 -0
- package/dist/handlers/tools/team.d.ts +11 -0
- package/dist/handlers/tools/team.d.ts.map +1 -0
- package/dist/handlers/tools/team.js +239 -0
- package/dist/handlers/tools/team.js.map +1 -0
- package/dist/server/McpServer.d.ts +4 -0
- package/dist/server/McpServer.d.ts.map +1 -1
- package/dist/server/McpServer.js +48 -297
- 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/transports/http.d.ts +66 -0
- package/dist/transports/http.d.ts.map +1 -0
- package/dist/transports/http.js +519 -0
- package/dist/transports/http.js.map +1 -0
- package/dist/types/entities.d.ts +101 -0
- package/dist/types/entities.d.ts.map +1 -0
- package/dist/types/entities.js +5 -0
- package/dist/types/entities.js.map +1 -0
- package/dist/types/filtering.d.ts +34 -0
- package/dist/types/filtering.d.ts.map +1 -0
- package/dist/types/filtering.js +5 -0
- package/dist/types/filtering.js.map +1 -0
- package/dist/types/github.d.ts +166 -0
- package/dist/types/github.d.ts.map +1 -0
- package/dist/types/github.js +5 -0
- package/dist/types/github.js.map +1 -0
- package/dist/types/index.d.ts +35 -292
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +2 -2
- package/dist/types/index.js.map +1 -1
- package/dist/utils/error-helpers.d.ts +37 -0
- package/dist/utils/error-helpers.d.ts.map +1 -0
- package/dist/utils/error-helpers.js +47 -0
- package/dist/utils/error-helpers.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/dist/vector/VectorSearchManager.d.ts.map +1 -1
- package/dist/vector/VectorSearchManager.js +9 -32
- package/dist/vector/VectorSearchManager.js.map +1 -1
- package/docker-compose.yml +11 -2
- 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/mcp-config-example.json +1 -0
- package/package.json +11 -9
- package/playwright.config.ts +29 -0
- package/releases/v4.5.0.md +116 -0
- package/releases/v5.0.0.md +105 -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 +45 -1
- package/src/constants/ServerInstructions.ts +133 -73
- package/src/constants/icons.ts +8 -7
- package/src/constants/server-instructions.md +268 -0
- package/src/database/SqliteAdapter.ts +358 -192
- package/src/database/schema.ts +125 -0
- package/src/filtering/ToolFilter.ts +13 -2
- package/src/github/GitHubIntegration.ts +1 -3
- package/src/handlers/prompts/github.ts +209 -0
- package/src/handlers/prompts/index.ts +10 -499
- package/src/handlers/prompts/workflow.ts +314 -0
- package/src/handlers/resources/core.ts +528 -0
- package/src/handlers/resources/github.ts +358 -0
- package/src/handlers/resources/graph.ts +254 -0
- package/src/handlers/resources/index.ts +23 -1570
- package/src/handlers/resources/shared.ts +103 -0
- package/src/handlers/resources/team.ts +133 -0
- package/src/handlers/resources/templates.ts +374 -0
- package/src/handlers/tools/admin.ts +285 -0
- package/src/handlers/tools/analytics.ts +301 -0
- package/src/handlers/tools/backup.ts +242 -0
- package/src/handlers/tools/core.ts +350 -0
- package/src/handlers/tools/export.ts +115 -0
- package/src/handlers/tools/github/helpers.ts +86 -0
- package/src/handlers/tools/github/insights-tools.ts +119 -0
- package/src/handlers/tools/github/issue-tools.ts +439 -0
- package/src/handlers/tools/github/kanban-tools.ts +134 -0
- package/src/handlers/tools/github/milestone-tools.ts +392 -0
- package/src/handlers/tools/github/mutation-tools.ts +17 -0
- package/src/handlers/tools/github/read-tools.ts +328 -0
- package/src/handlers/tools/github/schemas.ts +369 -0
- package/src/handlers/tools/github.ts +36 -0
- package/src/handlers/tools/index.ts +144 -3325
- package/src/handlers/tools/relationships.ts +358 -0
- package/src/handlers/tools/schemas.ts +132 -0
- package/src/handlers/tools/search.ts +343 -0
- package/src/handlers/tools/team.ts +273 -0
- package/src/server/McpServer.ts +63 -358
- package/src/server/Scheduler.ts +278 -0
- package/src/transports/http.ts +635 -0
- package/src/types/entities.ts +145 -0
- package/src/types/filtering.ts +54 -0
- package/src/types/github.ts +180 -0
- package/src/types/index.ts +67 -375
- package/src/utils/error-helpers.ts +52 -0
- package/src/utils/logger.ts +6 -3
- package/src/utils/security-utils.ts +0 -52
- package/src/vector/VectorSearchManager.ts +9 -33
- package/tests/constants/icons.test.ts +1 -2
- package/tests/constants/server-instructions.test.ts +30 -4
- package/tests/database/sqlite-adapter.test.ts +91 -7
- package/tests/e2e/auth.spec.ts +154 -0
- package/tests/e2e/health.spec.ts +63 -0
- package/tests/e2e/protocols.spec.ts +134 -0
- package/tests/e2e/resources.spec.ts +103 -0
- package/tests/e2e/scheduler.spec.ts +79 -0
- package/tests/e2e/security.spec.ts +91 -0
- package/tests/e2e/sessions.spec.ts +95 -0
- package/tests/e2e/stateless.spec.ts +121 -0
- package/tests/e2e/tools.spec.ts +111 -0
- package/tests/filtering/tool-filter.test.ts +46 -0
- package/tests/handlers/error-path-coverage.test.ts +324 -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-handler-coverage.test.ts +106 -0
- package/tests/handlers/prompt-handlers.test.ts +40 -0
- package/tests/handlers/resource-handler-coverage.test.ts +181 -0
- package/tests/handlers/resource-handlers.test.ts +33 -9
- package/tests/handlers/search-tool-handlers.test.ts +272 -0
- package/tests/handlers/targeted-gap-closure.test.ts +387 -0
- package/tests/handlers/team-resource-handlers.test.ts +156 -0
- package/tests/handlers/team-tool-handlers.test.ts +301 -0
- package/tests/handlers/tool-handler-coverage.test.ts +469 -0
- package/tests/handlers/tool-handlers.test.ts +2 -2
- package/tests/security/sql-injection.test.ts +3 -54
- package/tests/server/mcp-server.test.ts +503 -8
- package/tests/server/scheduler.test.ts +400 -0
- package/tests/transports/http-transport.test.ts +620 -0
- package/tests/vector/vector-search-manager.test.ts +60 -0
- package/vitest.config.ts +4 -1
- package/.memory-journal-team.db +0 -0
- package/.vscode/settings.json +0 -84
package/src/types/index.ts
CHANGED
|
@@ -1,63 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Memory Journal MCP Server - Type Definitions
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export type
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
target: string
|
|
43
|
-
|
|
44
|
-
/** Whether target is a group (true) or individual tool (false) */
|
|
45
|
-
isGroup: boolean
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Parsed tool filter configuration
|
|
50
|
-
*/
|
|
51
|
-
export interface ToolFilterConfig {
|
|
52
|
-
/** Original filter string */
|
|
53
|
-
raw: string
|
|
54
|
-
|
|
55
|
-
/** Parsed rules in order */
|
|
56
|
-
rules: ToolFilterRule[]
|
|
57
|
-
|
|
58
|
-
/** Set of enabled tool names after applying rules */
|
|
59
|
-
enabledTools: Set<string>
|
|
60
|
-
}
|
|
4
|
+
* Barrel file re-exporting all types from sub-modules, plus types
|
|
5
|
+
* that depend on external imports (SqliteAdapter, VectorSearchManager, etc.).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
import type { SqliteAdapter } from '../database/SqliteAdapter.js'
|
|
9
|
+
import type { VectorSearchManager } from '../vector/VectorSearchManager.js'
|
|
10
|
+
import type { GitHubIntegration } from '../github/GitHubIntegration.js'
|
|
11
|
+
import type { ProgressContext } from '../utils/progress-utils.js'
|
|
12
|
+
|
|
13
|
+
// Re-export sub-module types
|
|
14
|
+
export type { ToolGroup, MetaGroup, ToolFilterRule, ToolFilterConfig } from './filtering.js'
|
|
15
|
+
export type {
|
|
16
|
+
EntryType,
|
|
17
|
+
SignificanceType,
|
|
18
|
+
RelationshipType,
|
|
19
|
+
JournalEntry,
|
|
20
|
+
Tag,
|
|
21
|
+
Relationship,
|
|
22
|
+
Embedding,
|
|
23
|
+
ImportanceBreakdown,
|
|
24
|
+
ImportanceResult,
|
|
25
|
+
} from './entities.js'
|
|
26
|
+
export type {
|
|
27
|
+
GitHubProject,
|
|
28
|
+
GitHubIssue,
|
|
29
|
+
GitHubPullRequest,
|
|
30
|
+
GitHubMilestone,
|
|
31
|
+
GitHubWorkflowRun,
|
|
32
|
+
ProjectContext,
|
|
33
|
+
RepoStats,
|
|
34
|
+
TrafficData,
|
|
35
|
+
TrafficReferrer,
|
|
36
|
+
PopularPath,
|
|
37
|
+
ProjectV2StatusOption,
|
|
38
|
+
ProjectV2Item,
|
|
39
|
+
KanbanColumn,
|
|
40
|
+
KanbanBoard,
|
|
41
|
+
} from './github.js'
|
|
61
42
|
|
|
62
43
|
// ============================================================================
|
|
63
44
|
// MCP 2025-11-25 Annotations
|
|
@@ -117,6 +98,8 @@ export interface McpIcon {
|
|
|
117
98
|
// Tool, Resource, Prompt Definitions
|
|
118
99
|
// ============================================================================
|
|
119
100
|
|
|
101
|
+
import type { ToolGroup } from './filtering.js'
|
|
102
|
+
|
|
120
103
|
/**
|
|
121
104
|
* Tool definition for registration
|
|
122
105
|
*/
|
|
@@ -143,7 +126,33 @@ export interface ToolDefinition {
|
|
|
143
126
|
annotations: ToolAnnotations
|
|
144
127
|
|
|
145
128
|
/** Tool handler function */
|
|
146
|
-
handler: (params: unknown) =>
|
|
129
|
+
handler: (params: unknown) => unknown
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Tool handler configuration options
|
|
134
|
+
*/
|
|
135
|
+
export interface ToolHandlerConfig {
|
|
136
|
+
/** Default GitHub Project number for auto-assignment */
|
|
137
|
+
defaultProjectNumber?: number
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Tool execution context passed to all tool group modules
|
|
142
|
+
*/
|
|
143
|
+
export interface ToolContext {
|
|
144
|
+
/** Database adapter */
|
|
145
|
+
db: SqliteAdapter
|
|
146
|
+
/** Team database adapter (optional, requires TEAM_DB_PATH) */
|
|
147
|
+
teamDb?: SqliteAdapter
|
|
148
|
+
/** Vector search manager (optional) */
|
|
149
|
+
vectorManager?: VectorSearchManager
|
|
150
|
+
/** GitHub integration (optional) */
|
|
151
|
+
github?: GitHubIntegration
|
|
152
|
+
/** Handler configuration */
|
|
153
|
+
config?: ToolHandlerConfig
|
|
154
|
+
/** Progress reporting context */
|
|
155
|
+
progress?: ProgressContext
|
|
147
156
|
}
|
|
148
157
|
|
|
149
158
|
/**
|
|
@@ -193,323 +202,6 @@ export interface PromptDefinition {
|
|
|
193
202
|
handler: (args: Record<string, string>) => Promise<unknown>
|
|
194
203
|
}
|
|
195
204
|
|
|
196
|
-
// ============================================================================
|
|
197
|
-
// Database Entity Types
|
|
198
|
-
// ============================================================================
|
|
199
|
-
|
|
200
|
-
/**
|
|
201
|
-
* Entry types for journal entries
|
|
202
|
-
*/
|
|
203
|
-
export type EntryType =
|
|
204
|
-
| 'personal_reflection'
|
|
205
|
-
| 'project_decision'
|
|
206
|
-
| 'technical_achievement'
|
|
207
|
-
| 'bug_fix'
|
|
208
|
-
| 'feature_implementation'
|
|
209
|
-
| 'code_review'
|
|
210
|
-
| 'meeting_notes'
|
|
211
|
-
| 'learning'
|
|
212
|
-
| 'research'
|
|
213
|
-
| 'planning'
|
|
214
|
-
| 'retrospective'
|
|
215
|
-
| 'standup'
|
|
216
|
-
| 'other'
|
|
217
|
-
|
|
218
|
-
/**
|
|
219
|
-
* Significance types for important entries
|
|
220
|
-
*/
|
|
221
|
-
export type SignificanceType =
|
|
222
|
-
| 'milestone'
|
|
223
|
-
| 'breakthrough'
|
|
224
|
-
| 'technical_breakthrough'
|
|
225
|
-
| 'decision'
|
|
226
|
-
| 'lesson_learned'
|
|
227
|
-
| 'blocker_resolved'
|
|
228
|
-
| 'release'
|
|
229
|
-
| null
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Relationship types between entries
|
|
233
|
-
*
|
|
234
|
-
* Standard types:
|
|
235
|
-
* - evolves_from: Entry builds upon previous work
|
|
236
|
-
* - references: Entry mentions or links to another
|
|
237
|
-
* - implements: Entry implements a spec/design
|
|
238
|
-
* - clarifies: Entry explains or clarifies another
|
|
239
|
-
* - response_to: Entry responds to a question/issue
|
|
240
|
-
*
|
|
241
|
-
* Causal types (for decision tracing):
|
|
242
|
-
* - blocked_by: Entry was blocked by another (e.g., blocker → resolution)
|
|
243
|
-
* - resolved: Entry resolved/fixed an issue from another
|
|
244
|
-
* - caused: Entry caused or led to another outcome
|
|
245
|
-
*/
|
|
246
|
-
export type RelationshipType =
|
|
247
|
-
| 'evolves_from'
|
|
248
|
-
| 'references'
|
|
249
|
-
| 'implements'
|
|
250
|
-
| 'clarifies'
|
|
251
|
-
| 'response_to'
|
|
252
|
-
| 'blocked_by'
|
|
253
|
-
| 'resolved'
|
|
254
|
-
| 'caused'
|
|
255
|
-
|
|
256
|
-
/**
|
|
257
|
-
* Journal entry entity
|
|
258
|
-
*/
|
|
259
|
-
export interface JournalEntry {
|
|
260
|
-
id: number
|
|
261
|
-
entryType: EntryType
|
|
262
|
-
content: string
|
|
263
|
-
timestamp: string
|
|
264
|
-
isPersonal: boolean
|
|
265
|
-
significanceType: SignificanceType
|
|
266
|
-
autoContext: string | null
|
|
267
|
-
deletedAt: string | null
|
|
268
|
-
tags: string[]
|
|
269
|
-
// GitHub integration fields
|
|
270
|
-
projectNumber?: number | null
|
|
271
|
-
projectOwner?: string | null
|
|
272
|
-
issueNumber?: number | null
|
|
273
|
-
issueUrl?: string | null
|
|
274
|
-
prNumber?: number | null
|
|
275
|
-
prUrl?: string | null
|
|
276
|
-
prStatus?: string | null
|
|
277
|
-
workflowRunId?: number | null
|
|
278
|
-
workflowName?: string | null
|
|
279
|
-
workflowStatus?: string | null
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
/**
|
|
283
|
-
* Tag entity
|
|
284
|
-
*/
|
|
285
|
-
export interface Tag {
|
|
286
|
-
id: number
|
|
287
|
-
name: string
|
|
288
|
-
usageCount: number
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
/**
|
|
292
|
-
* Relationship entity
|
|
293
|
-
*/
|
|
294
|
-
export interface Relationship {
|
|
295
|
-
id: number
|
|
296
|
-
fromEntryId: number
|
|
297
|
-
toEntryId: number
|
|
298
|
-
relationshipType: RelationshipType
|
|
299
|
-
description: string | null
|
|
300
|
-
createdAt: string
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
/**
|
|
304
|
-
* Embedding entity for vector search
|
|
305
|
-
*/
|
|
306
|
-
export interface Embedding {
|
|
307
|
-
entryId: number
|
|
308
|
-
embedding: Float32Array
|
|
309
|
-
modelName: string
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
/**
|
|
313
|
-
* Importance scoring breakdown showing weighted component contributions
|
|
314
|
-
*/
|
|
315
|
-
export interface ImportanceBreakdown {
|
|
316
|
-
/** Significance type contribution (weight: 0.30) */
|
|
317
|
-
significance: number
|
|
318
|
-
/** Relationship count contribution (weight: 0.35) */
|
|
319
|
-
relationships: number
|
|
320
|
-
/** Causal relationship contribution (weight: 0.20) */
|
|
321
|
-
causal: number
|
|
322
|
-
/** Recency decay contribution (weight: 0.15) */
|
|
323
|
-
recency: number
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
/**
|
|
327
|
-
* Importance calculation result with total score and component breakdown
|
|
328
|
-
*/
|
|
329
|
-
export interface ImportanceResult {
|
|
330
|
-
/** Total importance score (0.0-1.0) */
|
|
331
|
-
score: number
|
|
332
|
-
/** Weighted component contributions */
|
|
333
|
-
breakdown: ImportanceBreakdown
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
// ============================================================================
|
|
337
|
-
// GitHub Integration Types
|
|
338
|
-
// ============================================================================
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* GitHub project information
|
|
342
|
-
*/
|
|
343
|
-
export interface GitHubProject {
|
|
344
|
-
number: number
|
|
345
|
-
title: string
|
|
346
|
-
url: string
|
|
347
|
-
state: 'OPEN' | 'CLOSED'
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* GitHub issue information
|
|
352
|
-
*/
|
|
353
|
-
export interface GitHubIssue {
|
|
354
|
-
number: number
|
|
355
|
-
title: string
|
|
356
|
-
url: string
|
|
357
|
-
state: 'OPEN' | 'CLOSED'
|
|
358
|
-
milestone?: { number: number; title: string } | null
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
/**
|
|
362
|
-
* GitHub pull request information
|
|
363
|
-
*/
|
|
364
|
-
export interface GitHubPullRequest {
|
|
365
|
-
number: number
|
|
366
|
-
title: string
|
|
367
|
-
url: string
|
|
368
|
-
state: 'OPEN' | 'CLOSED' | 'MERGED'
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
/**
|
|
372
|
-
* GitHub milestone information
|
|
373
|
-
*/
|
|
374
|
-
export interface GitHubMilestone {
|
|
375
|
-
number: number
|
|
376
|
-
title: string
|
|
377
|
-
description: string | null
|
|
378
|
-
state: 'open' | 'closed'
|
|
379
|
-
url: string
|
|
380
|
-
dueOn: string | null
|
|
381
|
-
openIssues: number
|
|
382
|
-
closedIssues: number
|
|
383
|
-
createdAt: string
|
|
384
|
-
updatedAt: string
|
|
385
|
-
creator: string | null
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
/**
|
|
389
|
-
* GitHub workflow run information
|
|
390
|
-
*/
|
|
391
|
-
export interface GitHubWorkflowRun {
|
|
392
|
-
id: number
|
|
393
|
-
name: string
|
|
394
|
-
status: 'queued' | 'in_progress' | 'completed'
|
|
395
|
-
conclusion: 'success' | 'failure' | 'cancelled' | 'skipped' | null
|
|
396
|
-
url: string
|
|
397
|
-
headBranch: string
|
|
398
|
-
headSha: string
|
|
399
|
-
createdAt: string
|
|
400
|
-
updatedAt: string
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
/**
|
|
404
|
-
* Auto-captured project context
|
|
405
|
-
*/
|
|
406
|
-
export interface ProjectContext {
|
|
407
|
-
repoName: string | null
|
|
408
|
-
branch: string | null
|
|
409
|
-
commit: string | null
|
|
410
|
-
remoteUrl: string | null
|
|
411
|
-
projects: GitHubProject[]
|
|
412
|
-
issues: GitHubIssue[]
|
|
413
|
-
pullRequests: GitHubPullRequest[]
|
|
414
|
-
workflowRuns: GitHubWorkflowRun[]
|
|
415
|
-
milestones: GitHubMilestone[]
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
// ============================================================================
|
|
419
|
-
// Repository Insights/Traffic Types
|
|
420
|
-
// ============================================================================
|
|
421
|
-
|
|
422
|
-
/**
|
|
423
|
-
* Repository statistics (stars, forks, watchers)
|
|
424
|
-
*/
|
|
425
|
-
export interface RepoStats {
|
|
426
|
-
stars: number
|
|
427
|
-
forks: number
|
|
428
|
-
watchers: number
|
|
429
|
-
openIssues: number
|
|
430
|
-
size: number // KB
|
|
431
|
-
defaultBranch: string
|
|
432
|
-
}
|
|
433
|
-
|
|
434
|
-
/**
|
|
435
|
-
* Aggregated traffic data (14-day rolling)
|
|
436
|
-
*/
|
|
437
|
-
export interface TrafficData {
|
|
438
|
-
clones: { total: number; unique: number; dailyAvg: number }
|
|
439
|
-
views: { total: number; unique: number; dailyAvg: number }
|
|
440
|
-
period: string // e.g. "14 days"
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* Traffic referrer source
|
|
445
|
-
*/
|
|
446
|
-
export interface TrafficReferrer {
|
|
447
|
-
referrer: string
|
|
448
|
-
count: number
|
|
449
|
-
uniques: number
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
/**
|
|
453
|
-
* Popular repository path
|
|
454
|
-
*/
|
|
455
|
-
export interface PopularPath {
|
|
456
|
-
path: string
|
|
457
|
-
title: string
|
|
458
|
-
count: number
|
|
459
|
-
uniques: number
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
// ============================================================================
|
|
463
|
-
// GitHub Projects v2 Kanban Types
|
|
464
|
-
// ============================================================================
|
|
465
|
-
|
|
466
|
-
/**
|
|
467
|
-
* Status option for single-select field in Projects v2
|
|
468
|
-
*/
|
|
469
|
-
export interface ProjectV2StatusOption {
|
|
470
|
-
id: string
|
|
471
|
-
name: string
|
|
472
|
-
color?: string
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
/**
|
|
476
|
-
* Project item in a Kanban board
|
|
477
|
-
*/
|
|
478
|
-
export interface ProjectV2Item {
|
|
479
|
-
id: string
|
|
480
|
-
title: string
|
|
481
|
-
url: string
|
|
482
|
-
type: 'ISSUE' | 'PULL_REQUEST' | 'DRAFT_ISSUE'
|
|
483
|
-
status: string | null
|
|
484
|
-
number?: number
|
|
485
|
-
labels?: string[]
|
|
486
|
-
assignees?: string[]
|
|
487
|
-
createdAt: string
|
|
488
|
-
updatedAt: string
|
|
489
|
-
}
|
|
490
|
-
|
|
491
|
-
/**
|
|
492
|
-
* Kanban column (grouped by Status)
|
|
493
|
-
*/
|
|
494
|
-
export interface KanbanColumn {
|
|
495
|
-
status: string
|
|
496
|
-
statusOptionId: string
|
|
497
|
-
items: ProjectV2Item[]
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
/**
|
|
501
|
-
* Full Kanban board response
|
|
502
|
-
*/
|
|
503
|
-
export interface KanbanBoard {
|
|
504
|
-
projectId: string
|
|
505
|
-
projectNumber: number
|
|
506
|
-
projectTitle: string
|
|
507
|
-
statusFieldId: string
|
|
508
|
-
statusOptions: ProjectV2StatusOption[]
|
|
509
|
-
columns: KanbanColumn[]
|
|
510
|
-
totalItems: number
|
|
511
|
-
}
|
|
512
|
-
|
|
513
205
|
// ============================================================================
|
|
514
206
|
// Configuration Types
|
|
515
207
|
// ============================================================================
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized Error Helpers for Memory Journal MCP
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent error formatting across all tool handlers.
|
|
5
|
+
* Follows the deterministic error handling standard from mysql-mcp:
|
|
6
|
+
* all errors return { success: false, error: "Human-readable message" }
|
|
7
|
+
* instead of throwing uncaught exceptions.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { ZodError } from 'zod'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Extract human-readable messages from a ZodError instead of raw JSON array.
|
|
14
|
+
* Maps each Zod issue to its path + message for clear validation feedback.
|
|
15
|
+
*/
|
|
16
|
+
export function formatZodError(error: ZodError): string {
|
|
17
|
+
return error.issues
|
|
18
|
+
.map((issue) => {
|
|
19
|
+
const path = issue.path.length > 0 ? `${issue.path.join('.')}: ` : ''
|
|
20
|
+
return `${path}${issue.message}`
|
|
21
|
+
})
|
|
22
|
+
.join('; ')
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Format any caught error into a structured handler error response.
|
|
27
|
+
*
|
|
28
|
+
* Handles ZodError (validation) and general errors (runtime).
|
|
29
|
+
* Use as the single catch block for all tool handlers:
|
|
30
|
+
*
|
|
31
|
+
* ```typescript
|
|
32
|
+
* handler: async (params) => {
|
|
33
|
+
* try {
|
|
34
|
+
* const parsed = Schema.parse(params);
|
|
35
|
+
* // ... domain logic ...
|
|
36
|
+
* return { success: true, ... };
|
|
37
|
+
* } catch (err) {
|
|
38
|
+
* return formatHandlerError(err);
|
|
39
|
+
* }
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export function formatHandlerError(err: unknown): {
|
|
44
|
+
success: false
|
|
45
|
+
error: string
|
|
46
|
+
} {
|
|
47
|
+
if (err instanceof ZodError) {
|
|
48
|
+
return { success: false, error: formatZodError(err) }
|
|
49
|
+
}
|
|
50
|
+
const message = err instanceof Error ? err.message : String(err)
|
|
51
|
+
return { success: false, error: message }
|
|
52
|
+
}
|
package/src/utils/logger.ts
CHANGED
|
@@ -97,11 +97,14 @@ class Logger {
|
|
|
97
97
|
}
|
|
98
98
|
|
|
99
99
|
setLevel(level: LogLevel): void {
|
|
100
|
-
|
|
100
|
+
if (level in LOG_LEVELS) {
|
|
101
|
+
this.minLevel = LOG_LEVELS[level]
|
|
102
|
+
}
|
|
101
103
|
}
|
|
102
104
|
}
|
|
103
105
|
|
|
104
|
-
// Get log level from environment
|
|
105
|
-
const
|
|
106
|
+
// Get log level from environment (validated against known levels)
|
|
107
|
+
const rawLevel = process.env['LOG_LEVEL'] ?? 'info'
|
|
108
|
+
const envLevel: LogLevel = rawLevel in LOG_LEVELS ? (rawLevel as LogLevel) : 'info'
|
|
106
109
|
|
|
107
110
|
export const logger = new Logger(envLevel)
|
|
@@ -32,16 +32,6 @@ export class InvalidDateFormatError extends SecurityError {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
/**
|
|
36
|
-
* Thrown when SQL injection patterns are detected in input
|
|
37
|
-
*/
|
|
38
|
-
export class SqlInjectionError extends SecurityError {
|
|
39
|
-
constructor(pattern: string) {
|
|
40
|
-
super(`Potential SQL injection detected: '${pattern}'`, 'SQL_INJECTION')
|
|
41
|
-
this.name = 'SqlInjectionError'
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
35
|
/**
|
|
46
36
|
* Thrown when path traversal is detected in input
|
|
47
37
|
*/
|
|
@@ -111,48 +101,6 @@ export function sanitizeSearchQuery(query: string): string {
|
|
|
111
101
|
return query.replace(/\\/g, '\\\\').replace(/%/g, '\\%').replace(/_/g, '\\_')
|
|
112
102
|
}
|
|
113
103
|
|
|
114
|
-
// ============================================================================
|
|
115
|
-
// SQL Injection Detection
|
|
116
|
-
// ============================================================================
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Patterns that indicate SQL injection attempts.
|
|
120
|
-
* Used for validation in edge cases where parameterized queries aren't possible.
|
|
121
|
-
*/
|
|
122
|
-
const SQL_INJECTION_PATTERNS = [
|
|
123
|
-
/;\s*(DROP|DELETE|INSERT|UPDATE|CREATE|ALTER|TRUNCATE)/i,
|
|
124
|
-
/--\s*/,
|
|
125
|
-
/\/\*[\s\S]*?\*\//,
|
|
126
|
-
/UNION\s+(ALL\s+)?SELECT/i,
|
|
127
|
-
/'\s*OR\s+['"]?1['"]?\s*=\s*['"]?1/i,
|
|
128
|
-
/ATTACH\s+DATABASE/i,
|
|
129
|
-
/DETACH\s+DATABASE/i,
|
|
130
|
-
/load_extension\s*\(/i,
|
|
131
|
-
] as const
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Checks if a string contains potential SQL injection patterns.
|
|
135
|
-
* This is a secondary defense layer; parameterized queries are the primary defense.
|
|
136
|
-
*
|
|
137
|
-
* @param input - The string to check
|
|
138
|
-
* @returns true if injection patterns are detected, false otherwise
|
|
139
|
-
*/
|
|
140
|
-
export function containsSqlInjection(input: string): boolean {
|
|
141
|
-
return SQL_INJECTION_PATTERNS.some((pattern) => pattern.test(input))
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
* Validates that input does not contain SQL injection patterns.
|
|
146
|
-
*
|
|
147
|
-
* @param input - The string to validate
|
|
148
|
-
* @throws SqlInjectionError if injection patterns are detected
|
|
149
|
-
*/
|
|
150
|
-
export function assertNoSqlInjection(input: string): void {
|
|
151
|
-
if (containsSqlInjection(input)) {
|
|
152
|
-
throw new SqlInjectionError(input.substring(0, 50))
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
104
|
// ============================================================================
|
|
157
105
|
// Path Validation
|
|
158
106
|
// ============================================================================
|
|
@@ -247,49 +247,25 @@ export class VectorSearchManager {
|
|
|
247
247
|
|
|
248
248
|
logger.info('Rebuilding vector index from database...', { module: 'VectorSearch' })
|
|
249
249
|
|
|
250
|
-
// Step 1: Get total entry count
|
|
250
|
+
// Step 1: Get total entry count for progress reporting
|
|
251
251
|
const totalEntries = db.getActiveEntryCount()
|
|
252
|
-
const dbIds = new Set<string>()
|
|
253
252
|
|
|
254
|
-
//
|
|
255
|
-
|
|
256
|
-
const page = db.getEntriesPage(offset, REBUILD_PAGE_SIZE)
|
|
257
|
-
for (const entry of page) {
|
|
258
|
-
dbIds.add(String(entry.id))
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
|
|
262
|
-
// Step 2: Clean up existing index items
|
|
263
|
-
// If the index is corrupted (e.g., from a process kill), recreate it
|
|
253
|
+
// Step 2: Clean up existing index — delete all items for clean re-index
|
|
254
|
+
// (No orphan detection needed since everything is re-inserted from scratch)
|
|
264
255
|
try {
|
|
265
256
|
const indexItems = await this.index.listItems()
|
|
266
|
-
let orphansRemoved = 0
|
|
267
257
|
for (const item of indexItems) {
|
|
268
|
-
if (!dbIds.has(item.id)) {
|
|
269
|
-
try {
|
|
270
|
-
await this.index.deleteItem(item.id)
|
|
271
|
-
orphansRemoved++
|
|
272
|
-
} catch {
|
|
273
|
-
// Ignore errors during cleanup
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
if (orphansRemoved > 0) {
|
|
278
|
-
logger.info(`Cleaned up ${String(orphansRemoved)} orphaned vector entries`, {
|
|
279
|
-
module: 'VectorSearch',
|
|
280
|
-
})
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// Step 3: Delete all remaining items to prepare for clean re-index
|
|
284
|
-
// This avoids the double-delete overhead of calling addEntry (upsert) per item
|
|
285
|
-
const remainingItems = await this.index.listItems()
|
|
286
|
-
for (const item of remainingItems) {
|
|
287
258
|
try {
|
|
288
259
|
await this.index.deleteItem(item.id)
|
|
289
260
|
} catch {
|
|
290
|
-
// Ignore
|
|
261
|
+
// Ignore individual deletion errors
|
|
291
262
|
}
|
|
292
263
|
}
|
|
264
|
+
if (indexItems.length > 0) {
|
|
265
|
+
logger.info(`Cleared ${String(indexItems.length)} items from vector index`, {
|
|
266
|
+
module: 'VectorSearch',
|
|
267
|
+
})
|
|
268
|
+
}
|
|
293
269
|
} catch (indexError) {
|
|
294
270
|
// Index files are corrupted — recreate from scratch
|
|
295
271
|
logger.warning('Vector index corrupted, recreating...', {
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
ICON_BRIEFING,
|
|
18
18
|
ICON_CLOCK,
|
|
19
19
|
ICON_TAG,
|
|
20
|
-
ICON_TEAM,
|
|
21
20
|
ICON_STAR,
|
|
22
21
|
ICON_ISSUE,
|
|
23
22
|
ICON_PR,
|
|
@@ -57,7 +56,7 @@ describe('Resource icons', () => {
|
|
|
57
56
|
{ name: 'ICON_BRIEFING', icon: ICON_BRIEFING },
|
|
58
57
|
{ name: 'ICON_CLOCK', icon: ICON_CLOCK },
|
|
59
58
|
{ name: 'ICON_TAG', icon: ICON_TAG },
|
|
60
|
-
|
|
59
|
+
|
|
61
60
|
{ name: 'ICON_STAR', icon: ICON_STAR },
|
|
62
61
|
{ name: 'ICON_ISSUE', icon: ICON_ISSUE },
|
|
63
62
|
{ name: 'ICON_PR', icon: ICON_PR },
|