@telvok/librarian-mcp 1.5.2 → 1.5.4

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.
@@ -1,9 +1,14 @@
1
1
  import type { ParseResult } from './types.js';
2
2
  /**
3
- * Parse a JSONL file (Anthropic MCP Memory / mcp-knowledge-graph format).
3
+ * Parse a JSONL file. Supports multiple formats:
4
4
  *
5
- * Input format:
6
- * {"type":"entity","name":"Stripe Webhooks","entityType":"concept","observations":["Need idempotency checks"]}
7
- * {"type":"relation","from":"Stripe Webhooks","to":"Payment Processing","relationType":"part_of"}
5
+ * mcp-knowledge-graph:
6
+ * {"type":"entity","name":"Topic","observations":["fact 1","fact 2"]}
7
+ *
8
+ * Generic memory formats:
9
+ * {"title":"Topic","content":"..."}
10
+ * {"content":"...","timestamp":"..."}
11
+ * {"text":"...","metadata":{}}
12
+ * {"memory":"...","created_at":"..."}
8
13
  */
9
14
  export declare function parseJSONL(filePath: string): Promise<ParseResult>;
@@ -1,10 +1,15 @@
1
1
  import * as fs from 'fs/promises';
2
2
  /**
3
- * Parse a JSONL file (Anthropic MCP Memory / mcp-knowledge-graph format).
3
+ * Parse a JSONL file. Supports multiple formats:
4
4
  *
5
- * Input format:
6
- * {"type":"entity","name":"Stripe Webhooks","entityType":"concept","observations":["Need idempotency checks"]}
7
- * {"type":"relation","from":"Stripe Webhooks","to":"Payment Processing","relationType":"part_of"}
5
+ * mcp-knowledge-graph:
6
+ * {"type":"entity","name":"Topic","observations":["fact 1","fact 2"]}
7
+ *
8
+ * Generic memory formats:
9
+ * {"title":"Topic","content":"..."}
10
+ * {"content":"...","timestamp":"..."}
11
+ * {"text":"...","metadata":{}}
12
+ * {"memory":"...","created_at":"..."}
8
13
  */
9
14
  export async function parseJSONL(filePath) {
10
15
  const entries = [];
@@ -17,28 +22,55 @@ export async function parseJSONL(filePath) {
17
22
  const line = lines[i];
18
23
  try {
19
24
  const item = JSON.parse(line);
20
- // Skip safety markers and relations
25
+ // Skip internal markers and relations
21
26
  if (item.type === '_aim' || item.type === 'relation') {
22
27
  skipped++;
23
28
  continue;
24
29
  }
25
- // Only process entities
26
- if (item.type === 'entity' && item.name) {
27
- // Skip if no observations (empty content)
28
- if (!item.observations || item.observations.length === 0) {
29
- skipped++;
30
- continue;
31
- }
32
- entries.push({
33
- title: item.name,
34
- content: item.observations.join('\n\n'),
35
- context: item.entityType || undefined,
36
- source: 'jsonl',
37
- });
38
- }
39
- else {
30
+ // Extract title (try multiple fields)
31
+ const title = item.name || item.title || item.key || `Entry ${i + 1}`;
32
+ // Extract content (try multiple fields)
33
+ let entryContent;
34
+ // Check observations array first (mcp-knowledge-graph)
35
+ if (item.observations && Array.isArray(item.observations) && item.observations.length > 0) {
36
+ entryContent = item.observations.join('\n\n');
37
+ }
38
+ // Fall back to common content fields
39
+ if (!entryContent) {
40
+ entryContent = item.content || item.text || item.description ||
41
+ item.value || item.memory || item.observation || item.body;
42
+ }
43
+ // Skip if no content found
44
+ if (!entryContent) {
40
45
  skipped++;
46
+ continue;
47
+ }
48
+ // Extract context
49
+ let context;
50
+ if (item.entityType) {
51
+ context = item.entityType;
52
+ }
53
+ else if (item.context) {
54
+ context = item.context;
55
+ }
56
+ else if (item.category) {
57
+ context = item.category;
58
+ }
59
+ else if (item.type && item.type !== 'entity' && item.type !== 'memory') {
60
+ context = item.type;
61
+ }
62
+ else if (item.tags && Array.isArray(item.tags)) {
63
+ context = item.tags.join(', ');
41
64
  }
65
+ entries.push({
66
+ title: String(title),
67
+ content: String(entryContent),
68
+ context,
69
+ intent: item.intent ? String(item.intent) : undefined,
70
+ reasoning: item.reasoning ? String(item.reasoning) : undefined,
71
+ example: item.example ? String(item.example) : undefined,
72
+ source: 'jsonl',
73
+ });
42
74
  }
43
75
  catch (parseError) {
44
76
  errors.push(`Line ${i + 1}: Invalid JSON - ${parseError instanceof Error ? parseError.message : String(parseError)}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telvok/librarian-mcp",
3
- "version": "1.5.2",
3
+ "version": "1.5.4",
4
4
  "description": "Knowledge capture MCP server - remember what you learn with AI",
5
5
  "type": "module",
6
6
  "main": "dist/server.js",