@memnexus-ai/cli 1.7.240 → 1.7.242
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/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +7 -4
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/commit-context.d.ts.map +1 -1
- package/dist/commands/commit-context.js +7 -3
- package/dist/commands/commit-context.js.map +1 -1
- package/dist/commands/config.d.ts.map +1 -1
- package/dist/commands/config.js +18 -8
- package/dist/commands/config.js.map +1 -1
- package/dist/commands/mcp.d.ts +15 -0
- package/dist/commands/mcp.d.ts.map +1 -1
- package/dist/commands/mcp.js +47 -66
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/memories.d.ts.map +1 -1
- package/dist/commands/memories.js +96 -71
- package/dist/commands/memories.js.map +1 -1
- package/dist/commands/system.d.ts.map +1 -1
- package/dist/commands/system.js +4 -2
- package/dist/commands/system.js.map +1 -1
- package/dist/lib/errors.d.ts.map +1 -1
- package/dist/lib/errors.js +17 -11
- package/dist/lib/errors.js.map +1 -1
- package/dist/lib/formatters.d.ts.map +1 -1
- package/dist/lib/formatters.js +46 -26
- package/dist/lib/formatters.js.map +1 -1
- package/dist/lib/mcp-session-errors.d.ts +43 -0
- package/dist/lib/mcp-session-errors.d.ts.map +1 -0
- package/dist/lib/mcp-session-errors.js +67 -0
- package/dist/lib/mcp-session-errors.js.map +1 -0
- package/dist/lib/terminal-safe.d.ts +8 -5
- package/dist/lib/terminal-safe.d.ts.map +1 -1
- package/dist/lib/terminal-safe.js +81 -9
- package/dist/lib/terminal-safe.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memories.d.ts","sourceRoot":"","sources":["../../src/commands/memories.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAapC,OAAO,EACL,gBAAgB,EAChB,yBAAyB,EACzB,YAAY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zC,aAAa,GAAE,MAAqC,GACnD,OAAO,CAAC,IAAI,CAAC,CAqFf;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CA4wD/D;AAsZD;;;GAGG;AACH,wBAAgB,kCAAkC,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAkN1E;AAED;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CA6ErE;AAED;;;GAGG;AACH,wBAAgB,kCAAkC,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAsE1E;AA0DD;;;;;;GAMG;AACH,eAAO,MAAM,0BAA0B,OAAO,CAAC;AAE/C;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CAoL7D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CA+G7D;AAuLD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CA0J5D;AAoPD;;;GAGG;AACH,wBAAgB,2BAA2B,CAAC,QAAQ,EAAE,OAAO,GAAG,IAAI,CA0PnE"}
|
|
@@ -87,6 +87,28 @@ const content_input_1 = require("../lib/content-input");
|
|
|
87
87
|
const fs = __importStar(require("fs"));
|
|
88
88
|
const os = __importStar(require("os"));
|
|
89
89
|
const path = __importStar(require("path"));
|
|
90
|
+
const terminal_safe_1 = require("../lib/terminal-safe");
|
|
91
|
+
/**
|
|
92
|
+
* Memory content, titles, topics, facts and ids are server data, and some of
|
|
93
|
+
* it quotes text an agent or a cloned repository wrote. The human-readable
|
|
94
|
+
* renderers in this file print it with console.log, not through printOutput,
|
|
95
|
+
* so each value is sanitized where it is printed (CWE-150, security review of
|
|
96
|
+
* #5733). safeBlock keeps newlines and tabs, for multi-line content; safeText
|
|
97
|
+
* removes them, for a value printed inside one line. Both apply String() as a
|
|
98
|
+
* template literal would, so a missing value still prints "undefined". They
|
|
99
|
+
* run before smartTruncate and highlightTerms, so the highlight colours that
|
|
100
|
+
* highlightTerms adds are kept. JSON and YAML output paths are not changed.
|
|
101
|
+
*/
|
|
102
|
+
const safeText = (value) => (0, terminal_safe_1.sanitizeTerminalText)(String(value));
|
|
103
|
+
const safeBlock = (value) => (0, terminal_safe_1.sanitizeTerminalBlock)(String(value));
|
|
104
|
+
/**
|
|
105
|
+
* Quote one CSV field per RFC 4180: wrap it in double quotes when it holds a
|
|
106
|
+
* comma, a double quote or a line break, and double each inner quote. Stats
|
|
107
|
+
* buckets can be topic names, which may hold a comma (#5733 review).
|
|
108
|
+
*/
|
|
109
|
+
function csvField(value) {
|
|
110
|
+
return /[",\r\n]/.test(value) ? `"${value.replace(/"/g, '""')}"` : value;
|
|
111
|
+
}
|
|
90
112
|
// ── Cross-process bulk-delete guard (P0 #4144 fix-forward) ─────────────────
|
|
91
113
|
// When an agent pipes `mx memories search | xargs mx memories delete`, each
|
|
92
114
|
// delete is a separate process — a module-level counter resets every time.
|
|
@@ -405,7 +427,7 @@ function printMemoryWithDetail(memory, format, opts = {}) {
|
|
|
405
427
|
console.log(chalk_1.default.cyan.bold(`Facts (${memory.facts.length}):`));
|
|
406
428
|
for (const fact of memory.facts) {
|
|
407
429
|
const conf = fact.confidence != null ? ` ${chalk_1.default.gray(`(${Math.round(fact.confidence * 100)}%)`)}` : '';
|
|
408
|
-
console.log(` ${fact.subject} ${chalk_1.default.yellow(fact.predicate)} ${fact.object}${conf}`);
|
|
430
|
+
console.log(` ${safeText(fact.subject)} ${chalk_1.default.yellow(safeText(fact.predicate))} ${safeText(fact.object)}${conf}`);
|
|
409
431
|
}
|
|
410
432
|
}
|
|
411
433
|
// Relationships
|
|
@@ -415,11 +437,11 @@ function printMemoryWithDetail(memory, format, opts = {}) {
|
|
|
415
437
|
for (const rel of memory.relationships) {
|
|
416
438
|
const arrow = rel.direction === 'outgoing' ? '\u2192' : '\u2190';
|
|
417
439
|
const conf = rel.confidence != null ? ` ${chalk_1.default.gray(`(${Math.round(rel.confidence * 100)}%)`)}` : '';
|
|
418
|
-
console.log(` ${chalk_1.default.yellow(rel.type)} ${arrow} ${rel.targetMemoryId}${conf}`);
|
|
440
|
+
console.log(` ${chalk_1.default.yellow(safeText(rel.type))} ${arrow} ${safeText(rel.targetMemoryId)}${conf}`);
|
|
419
441
|
if (rel.reason)
|
|
420
|
-
console.log(` ${chalk_1.default.gray(rel.reason)}`);
|
|
442
|
+
console.log(` ${chalk_1.default.gray(safeText(rel.reason))}`);
|
|
421
443
|
if (rel.targetPreview)
|
|
422
|
-
console.log(` ${chalk_1.default.gray(rel.targetPreview)}`);
|
|
444
|
+
console.log(` ${chalk_1.default.gray(safeBlock(rel.targetPreview))}`);
|
|
423
445
|
}
|
|
424
446
|
}
|
|
425
447
|
// Conversation context
|
|
@@ -428,12 +450,12 @@ function printMemoryWithDetail(memory, format, opts = {}) {
|
|
|
428
450
|
console.log('');
|
|
429
451
|
console.log(chalk_1.default.cyan.bold('Conversation Context:'));
|
|
430
452
|
if (ctx.title)
|
|
431
|
-
console.log(` Title: ${ctx.title}`);
|
|
453
|
+
console.log(` Title: ${safeText(ctx.title)}`);
|
|
432
454
|
if (ctx.position != null && ctx.memoryCount != null) {
|
|
433
|
-
console.log(` Position: ${ctx.position} of ${ctx.memoryCount}`);
|
|
455
|
+
console.log(` Position: ${safeText(ctx.position)} of ${safeText(ctx.memoryCount)}`);
|
|
434
456
|
}
|
|
435
457
|
if (ctx.conversationId)
|
|
436
|
-
console.log(` ID: ${chalk_1.default.gray(ctx.conversationId)}`);
|
|
458
|
+
console.log(` ID: ${chalk_1.default.gray(safeText(ctx.conversationId))}`);
|
|
437
459
|
}
|
|
438
460
|
}
|
|
439
461
|
/**
|
|
@@ -457,7 +479,7 @@ async function handleBatchMemoryGet(ids, options) {
|
|
|
457
479
|
const result = response.data;
|
|
458
480
|
if (result && result.meta && result.meta.missing && result.meta.missing.length > 0) {
|
|
459
481
|
spinner.warn(`Found ${result.meta.found} of ${result.meta.requested} memories`);
|
|
460
|
-
console.log(chalk_1.default.yellow(`Missing IDs: ${result.meta.missing.join(', ')}`));
|
|
482
|
+
console.log(chalk_1.default.yellow(`Missing IDs: ${safeText(result.meta.missing.join(', '))}`));
|
|
461
483
|
}
|
|
462
484
|
else {
|
|
463
485
|
spinner.succeed(`Retrieved ${result?.data?.length ?? 0} memories`);
|
|
@@ -493,13 +515,13 @@ async function handleBatchMemoryGet(ids, options) {
|
|
|
493
515
|
if (i > 0) {
|
|
494
516
|
console.log(chalk_1.default.gray('─'.repeat(60)));
|
|
495
517
|
}
|
|
496
|
-
console.log(chalk_1.default.bold(`Memory: ${memory.id}`));
|
|
518
|
+
console.log(chalk_1.default.bold(`Memory: ${safeText(memory.id)}`));
|
|
497
519
|
console.log(chalk_1.default.gray(`Created: ${(0, date_utils_1.formatApiDate)(memory.createdAt)}`));
|
|
498
520
|
if (memory.topics && memory.topics.length > 0) {
|
|
499
|
-
console.log(chalk_1.default.blue(`Topics: ${memory.topics.join(', ')}`));
|
|
521
|
+
console.log(chalk_1.default.blue(`Topics: ${safeText(memory.topics.join(', '))}`));
|
|
500
522
|
}
|
|
501
523
|
console.log('');
|
|
502
|
-
console.log(memory.content);
|
|
524
|
+
console.log(safeBlock(memory.content));
|
|
503
525
|
}
|
|
504
526
|
console.log(chalk_1.default.gray('═'.repeat(60)));
|
|
505
527
|
}
|
|
@@ -852,7 +874,7 @@ async function handleBatchDelete(rawIds, options, mode) {
|
|
|
852
874
|
if (result.errors.length > 0) {
|
|
853
875
|
console.log(chalk_1.default.yellow(`\n${result.errors.length} failure(s):`));
|
|
854
876
|
for (const e of result.errors) {
|
|
855
|
-
console.log(` ${e.id}: ${e.error}`);
|
|
877
|
+
console.log(` ${safeText(e.id)}: ${safeText(e.error)}`);
|
|
856
878
|
}
|
|
857
879
|
}
|
|
858
880
|
if (result.aborted && result.notAttempted > 0) {
|
|
@@ -1630,13 +1652,13 @@ function registerMemoriesCommands(program) {
|
|
|
1630
1652
|
if (matches.length > 1) {
|
|
1631
1653
|
spinner.fail(`Ambiguous ID prefix: ${singleId} matches ${matches.length} memories`);
|
|
1632
1654
|
console.log(chalk_1.default.yellow('\nMatching IDs:'));
|
|
1633
|
-
matches.forEach((m) => console.log(` ${m.id}`));
|
|
1655
|
+
matches.forEach((m) => console.log(` ${safeText(m.id)}`));
|
|
1634
1656
|
console.log(chalk_1.default.gray('\nUse a longer prefix to uniquely identify the memory.'));
|
|
1635
1657
|
return;
|
|
1636
1658
|
}
|
|
1637
1659
|
resolvedMemory = matches[0];
|
|
1638
1660
|
memoryId = resolvedMemory.id;
|
|
1639
|
-
spinner.succeed(`Found memory: ${memoryId}`);
|
|
1661
|
+
spinner.succeed(`Found memory: ${safeText(memoryId)}`);
|
|
1640
1662
|
}
|
|
1641
1663
|
// Check if any discovery option is specified
|
|
1642
1664
|
const hasSimilar = options.similar;
|
|
@@ -1968,10 +1990,10 @@ function registerMemoriesCommands(program) {
|
|
|
1968
1990
|
}
|
|
1969
1991
|
if (upserted) {
|
|
1970
1992
|
const version = meta?.version || 'new';
|
|
1971
|
-
spinner.succeed(`Named memory '${memoryData.name}' updated (v${version}) via auto-upsert. ID: ${memory?.id}`);
|
|
1993
|
+
spinner.succeed(`Named memory '${memoryData.name}' updated (v${safeText(version)}) via auto-upsert. ID: ${safeText(memory?.id)}`);
|
|
1972
1994
|
if (meta?.previousVersionId) {
|
|
1973
1995
|
if (options.format !== 'json' && options.format !== 'yaml') {
|
|
1974
|
-
console.log(chalk_1.default.gray(`Previous version: ${meta.previousVersionId}`));
|
|
1996
|
+
console.log(chalk_1.default.gray(`Previous version: ${safeText(meta.previousVersionId)}`));
|
|
1975
1997
|
}
|
|
1976
1998
|
}
|
|
1977
1999
|
}
|
|
@@ -1980,13 +2002,13 @@ function registerMemoriesCommands(program) {
|
|
|
1980
2002
|
? `Named memory '${memoryData.name}' created (v1) with`
|
|
1981
2003
|
: 'Memory created with';
|
|
1982
2004
|
if (isNewConversation && meta?.conversationCreated) {
|
|
1983
|
-
spinner.succeed(`New conversation created: ${meta.conversationId}\n${nameLabel} ID: ${memory?.id}`);
|
|
2005
|
+
spinner.succeed(`New conversation created: ${safeText(meta.conversationId)}\n${nameLabel} ID: ${safeText(memory?.id)}`);
|
|
1984
2006
|
if (options.format !== 'json' && options.format !== 'yaml') {
|
|
1985
|
-
console.log(chalk_1.default.gray(`\nSession ID: ${meta.sessionId}`));
|
|
2007
|
+
console.log(chalk_1.default.gray(`\nSession ID: ${safeText(meta.sessionId)}`));
|
|
1986
2008
|
}
|
|
1987
2009
|
}
|
|
1988
2010
|
else {
|
|
1989
|
-
spinner.succeed(`${nameLabel} ID: ${memory?.id}`);
|
|
2011
|
+
spinner.succeed(`${nameLabel} ID: ${safeText(memory?.id)}`);
|
|
1990
2012
|
}
|
|
1991
2013
|
}
|
|
1992
2014
|
// Handle --supersedes flag: create SUPERSEDES relationship
|
|
@@ -2128,10 +2150,10 @@ function registerMemoriesCommands(program) {
|
|
|
2128
2150
|
const response = await retryWrite(() => (0, api_client_1.getSdk)().memories.updateNamedMemory(options.name, updates));
|
|
2129
2151
|
const memory = response.data?.data;
|
|
2130
2152
|
const meta = response.data?.meta;
|
|
2131
|
-
spinner.succeed(`Named memory '${options.name}' updated to v${meta?.version}`);
|
|
2153
|
+
spinner.succeed(`Named memory '${options.name}' updated to v${safeText(meta?.version)}`);
|
|
2132
2154
|
if (meta?.previousVersionId) {
|
|
2133
2155
|
if (options.format !== 'json' && options.format !== 'yaml') {
|
|
2134
|
-
console.log(chalk_1.default.gray(`Previous version: ${meta.previousVersionId}`));
|
|
2156
|
+
console.log(chalk_1.default.gray(`Previous version: ${safeText(meta.previousVersionId)}`));
|
|
2135
2157
|
}
|
|
2136
2158
|
}
|
|
2137
2159
|
(0, formatters_1.printOutput)(memory, options.format);
|
|
@@ -2741,7 +2763,7 @@ function registerMemoriesCommands(program) {
|
|
|
2741
2763
|
const m = result.memory; // Extract the nested memory object
|
|
2742
2764
|
const score = result.score;
|
|
2743
2765
|
// Smart truncation with term highlighting
|
|
2744
|
-
const content = m.content || '';
|
|
2766
|
+
const content = safeBlock(m.content || '');
|
|
2745
2767
|
const truncatedContent = smartTruncate(content, previewLength, options.query);
|
|
2746
2768
|
const highlightedContent = highlightTerms(truncatedContent, options.query);
|
|
2747
2769
|
// Format topics for display
|
|
@@ -2782,7 +2804,7 @@ function registerMemoriesCommands(program) {
|
|
|
2782
2804
|
r.matchedVia.forEach((b) => allBranches.add(b));
|
|
2783
2805
|
}
|
|
2784
2806
|
}
|
|
2785
|
-
const branchInfo = allBranches.size > 2 ? ` (branches: ${[...allBranches].join(', ')})` : '';
|
|
2807
|
+
const branchInfo = allBranches.size > 2 ? ` (branches: ${safeText([...allBranches].join(', '))})` : '';
|
|
2786
2808
|
console.log(chalk_1.default.gray(`\nFound ${resultCount} results using ${searchMethodUsed} search${branchInfo}`));
|
|
2787
2809
|
const tableMarker = (0, renderable_retrieval_1.degradationSummaryLine)(search.health);
|
|
2788
2810
|
if (tableMarker) {
|
|
@@ -2797,9 +2819,9 @@ function registerMemoriesCommands(program) {
|
|
|
2797
2819
|
if (temporal?.temporalFieldsIncluded) {
|
|
2798
2820
|
const filters = [];
|
|
2799
2821
|
if (temporal.eventTimeRange?.from)
|
|
2800
|
-
filters.push(`from: ${temporal.eventTimeRange.from}`);
|
|
2822
|
+
filters.push(`from: ${safeText(temporal.eventTimeRange.from)}`);
|
|
2801
2823
|
if (temporal.eventTimeRange?.to)
|
|
2802
|
-
filters.push(`to: ${temporal.eventTimeRange.to}`);
|
|
2824
|
+
filters.push(`to: ${safeText(temporal.eventTimeRange.to)}`);
|
|
2803
2825
|
if (filters.length > 0) {
|
|
2804
2826
|
console.log(chalk_1.default.gray(`Time filter: ${filters.join(', ')}`));
|
|
2805
2827
|
}
|
|
@@ -2961,16 +2983,16 @@ function displayTimelineResults(results, query, previewLength, health) {
|
|
|
2961
2983
|
// Format effective state indicator
|
|
2962
2984
|
const stateIndicator = formatStateIndicator(effectiveState);
|
|
2963
2985
|
// Truncate and highlight content
|
|
2964
|
-
const content = m.content || '';
|
|
2965
|
-
const firstLine = content.split('\n')[0] || '';
|
|
2986
|
+
const content = safeBlock(m.content || '');
|
|
2987
|
+
const firstLine = safeText(content.split('\n')[0] || '');
|
|
2966
2988
|
const truncatedContent = smartTruncate(firstLine, Math.min(previewLength, 80), query);
|
|
2967
2989
|
const highlightedContent = highlightTerms(truncatedContent, query);
|
|
2968
2990
|
// Display the timeline entry header
|
|
2969
2991
|
console.log(`${chalk_1.default.gray(formattedTime)} ${stateIndicator} ${highlightedContent}`);
|
|
2970
|
-
console.log(chalk_1.default.gray(` ID: ${m.id}`));
|
|
2992
|
+
console.log(chalk_1.default.gray(` ID: ${safeText(m.id)}`));
|
|
2971
2993
|
// Show topics if available
|
|
2972
2994
|
if (m.topics && m.topics.length > 0) {
|
|
2973
|
-
const topicsStr = m.topics.slice(0, 4).join(', ');
|
|
2995
|
+
const topicsStr = safeText(m.topics.slice(0, 4).join(', '));
|
|
2974
2996
|
const moreCount = m.topics.length > 4 ? ` +${m.topics.length - 4} more` : '';
|
|
2975
2997
|
console.log(chalk_1.default.gray(` Topics: ${topicsStr}${moreCount}`));
|
|
2976
2998
|
}
|
|
@@ -3112,15 +3134,16 @@ async function handleMemoryDiscovery(memoryId, options) {
|
|
|
3112
3134
|
// Display source memory info
|
|
3113
3135
|
if (sourceMemory) {
|
|
3114
3136
|
console.log(chalk_1.default.cyan('\n📌 Source Memory:'));
|
|
3115
|
-
console.log(chalk_1.default.gray(` ID: ${sourceMemory.id}`));
|
|
3116
|
-
|
|
3137
|
+
console.log(chalk_1.default.gray(` ID: ${safeText(sourceMemory.id)}`));
|
|
3138
|
+
const sourceContent = safeBlock(sourceMemory.content);
|
|
3139
|
+
console.log(chalk_1.default.gray(` Content: ${sourceContent.substring(0, 80)}${sourceContent.length > 80 ? '...' : ''}`));
|
|
3117
3140
|
if (sourceMemory.topics?.length > 0) {
|
|
3118
|
-
console.log(chalk_1.default.gray(` Topics: ${sourceMemory.topics.join(', ')}`));
|
|
3141
|
+
console.log(chalk_1.default.gray(` Topics: ${safeText(sourceMemory.topics.join(', '))}`));
|
|
3119
3142
|
}
|
|
3120
3143
|
}
|
|
3121
3144
|
// Display conversation ID if available
|
|
3122
3145
|
if (options.conversation && result.conversationId) {
|
|
3123
|
-
console.log(chalk_1.default.cyan(`\n💬 Conversation: ${result.conversationId}`));
|
|
3146
|
+
console.log(chalk_1.default.cyan(`\n💬 Conversation: ${safeText(result.conversationId)}`));
|
|
3124
3147
|
}
|
|
3125
3148
|
else if (options.conversation && !result.conversationId) {
|
|
3126
3149
|
console.log(chalk_1.default.yellow('\n⚠️ This memory is not part of a conversation'));
|
|
@@ -3158,7 +3181,7 @@ async function handleMemoryDiscovery(memoryId, options) {
|
|
|
3158
3181
|
console.log(chalk_1.default.gray('\nShared topics per memory:'));
|
|
3159
3182
|
memories.forEach((item, index) => {
|
|
3160
3183
|
if (item.sharedTopics?.length > 0) {
|
|
3161
|
-
console.log(chalk_1.default.gray(` ${index + 1}. ${item.sharedTopics.join(', ')}`));
|
|
3184
|
+
console.log(chalk_1.default.gray(` ${index + 1}. ${safeText(item.sharedTopics.join(', '))}`));
|
|
3162
3185
|
}
|
|
3163
3186
|
});
|
|
3164
3187
|
}
|
|
@@ -3308,7 +3331,7 @@ function registerMemoryRelationshipCommands(memories) {
|
|
|
3308
3331
|
const spinner = (0, spinner_1.createSpinner)('Creating relationship...', options.format).start();
|
|
3309
3332
|
const response = await retryWrite(() => (0, api_client_1.getSdk)().memories.createMemoryRelationship(id, relationshipData));
|
|
3310
3333
|
const relationship = response.data?.data;
|
|
3311
|
-
spinner.succeed(`Relationship created: ${id} ${relationship?.type} ${relationshipData.targetMemoryId}`);
|
|
3334
|
+
spinner.succeed(`Relationship created: ${id} ${safeText(relationship?.type)} ${relationshipData.targetMemoryId}`);
|
|
3312
3335
|
(0, formatters_1.printOutput)(relationship, options.format);
|
|
3313
3336
|
}
|
|
3314
3337
|
catch (error) {
|
|
@@ -3385,8 +3408,9 @@ function registerMemoryTimelineCommand(memories) {
|
|
|
3385
3408
|
const source = result?.data?.memory;
|
|
3386
3409
|
if (source) {
|
|
3387
3410
|
console.log(chalk_1.default.cyan('\n📌 Source Memory:'));
|
|
3388
|
-
console.log(chalk_1.default.gray(` ID: ${source.id}`));
|
|
3389
|
-
|
|
3411
|
+
console.log(chalk_1.default.gray(` ID: ${safeText(source.id)}`));
|
|
3412
|
+
const sourceContent = safeBlock(source.content);
|
|
3413
|
+
console.log(chalk_1.default.gray(` Content: ${sourceContent.substring(0, 60)}${sourceContent.length > 60 ? '...' : ''}`));
|
|
3390
3414
|
if (source.effectiveState && source.effectiveState !== 'current') {
|
|
3391
3415
|
console.log(chalk_1.default.gray(` State: ${formatEffectiveState(source.effectiveState)}`));
|
|
3392
3416
|
}
|
|
@@ -3396,8 +3420,8 @@ function registerMemoryTimelineCommand(memories) {
|
|
|
3396
3420
|
if (precedingMemories.length > 0) {
|
|
3397
3421
|
console.log(chalk_1.default.cyan(`\n⬆️ Preceding (${precedingMemories.length}):`));
|
|
3398
3422
|
precedingMemories.forEach((m, i) => {
|
|
3399
|
-
const state = m.effectiveState !== 'current' ? ` [${m.effectiveState}]` : '';
|
|
3400
|
-
console.log(chalk_1.default.gray(` ${i + 1}. ${m.id
|
|
3423
|
+
const state = m.effectiveState !== 'current' ? ` [${safeText(m.effectiveState)}]` : '';
|
|
3424
|
+
console.log(chalk_1.default.gray(` ${i + 1}. ${safeText(m.id).substring(0, 8)}... ${safeBlock(m.content).substring(0, 50)}...${state}`));
|
|
3401
3425
|
});
|
|
3402
3426
|
}
|
|
3403
3427
|
// Display following memories
|
|
@@ -3405,8 +3429,8 @@ function registerMemoryTimelineCommand(memories) {
|
|
|
3405
3429
|
if (followingMemories.length > 0) {
|
|
3406
3430
|
console.log(chalk_1.default.cyan(`\n⬇️ Following (${followingMemories.length}):`));
|
|
3407
3431
|
followingMemories.forEach((m, i) => {
|
|
3408
|
-
const state = m.effectiveState !== 'current' ? ` [${m.effectiveState}]` : '';
|
|
3409
|
-
console.log(chalk_1.default.gray(` ${i + 1}. ${m.id
|
|
3432
|
+
const state = m.effectiveState !== 'current' ? ` [${safeText(m.effectiveState)}]` : '';
|
|
3433
|
+
console.log(chalk_1.default.gray(` ${i + 1}. ${safeText(m.id).substring(0, 8)}... ${safeBlock(m.content).substring(0, 50)}...${state}`));
|
|
3410
3434
|
});
|
|
3411
3435
|
}
|
|
3412
3436
|
}
|
|
@@ -3531,7 +3555,7 @@ function formatEffectiveState(state) {
|
|
|
3531
3555
|
case 'contradicted':
|
|
3532
3556
|
return chalk_1.default.red(state);
|
|
3533
3557
|
default:
|
|
3534
|
-
return state || 'current';
|
|
3558
|
+
return safeText(state || 'current');
|
|
3535
3559
|
}
|
|
3536
3560
|
}
|
|
3537
3561
|
/**
|
|
@@ -3646,7 +3670,7 @@ function registerDigestCommand(memories) {
|
|
|
3646
3670
|
}
|
|
3647
3671
|
// LLM output — raw digest text only
|
|
3648
3672
|
if (options.format === 'llm') {
|
|
3649
|
-
console.log(digest);
|
|
3673
|
+
console.log(safeBlock(digest));
|
|
3650
3674
|
return;
|
|
3651
3675
|
}
|
|
3652
3676
|
// Default display with box formatting
|
|
@@ -3765,7 +3789,7 @@ function registerStatusCommand(memories) {
|
|
|
3765
3789
|
return;
|
|
3766
3790
|
}
|
|
3767
3791
|
if (options.format === 'llm') {
|
|
3768
|
-
console.log(digest);
|
|
3792
|
+
console.log(safeBlock(digest));
|
|
3769
3793
|
return;
|
|
3770
3794
|
}
|
|
3771
3795
|
displayDigest(digest, metadata, sources, options, keyFacts, entities, effectiveStateBreakdown, renderable.health);
|
|
@@ -3839,7 +3863,7 @@ function displayDigest(digest, metadata, sources, options, keyFacts, entities, e
|
|
|
3839
3863
|
const border = '═'.repeat(width);
|
|
3840
3864
|
// Format header info
|
|
3841
3865
|
const recentLabel = options.recent ? ` (last ${options.recent})` : '';
|
|
3842
|
-
const headerLine1 = `Digest: "${metadata.query}"${recentLabel}`;
|
|
3866
|
+
const headerLine1 = `Digest: "${safeText(metadata.query)}"${recentLabel}`;
|
|
3843
3867
|
const headerLine2 = `Sources: ${metadata.sourcesUsed} memories across ` +
|
|
3844
3868
|
`${metadata.conversationsSpanned} conversations`;
|
|
3845
3869
|
// Header box
|
|
@@ -3856,19 +3880,20 @@ function displayDigest(digest, metadata, sources, options, keyFacts, entities, e
|
|
|
3856
3880
|
}
|
|
3857
3881
|
// Digest content
|
|
3858
3882
|
console.log('');
|
|
3859
|
-
console.log(digest);
|
|
3883
|
+
console.log(safeBlock(digest));
|
|
3860
3884
|
// Key facts
|
|
3861
3885
|
if (keyFacts && keyFacts.length > 0) {
|
|
3862
3886
|
console.log('');
|
|
3863
3887
|
console.log(chalk_1.default.yellow.bold('Key Facts'));
|
|
3864
3888
|
for (const fact of keyFacts.slice(0, 10)) {
|
|
3865
|
-
console.log(` ${chalk_1.default.gray('•')} ${fact.subject} ${fact.predicate} ${fact.object}`);
|
|
3889
|
+
console.log(` ${chalk_1.default.gray('•')} ${safeText(fact.subject)} ${safeText(fact.predicate)} ${safeText(fact.object)}`);
|
|
3866
3890
|
}
|
|
3867
3891
|
}
|
|
3868
3892
|
// Entities
|
|
3869
3893
|
if (entities && entities.length > 0) {
|
|
3870
3894
|
console.log('');
|
|
3871
|
-
console.log(chalk_1.default.cyan.bold('Entities: ') +
|
|
3895
|
+
console.log(chalk_1.default.cyan.bold('Entities: ') +
|
|
3896
|
+
chalk_1.default.gray(safeText(entities.map((e) => e.name).join(', '))));
|
|
3872
3897
|
}
|
|
3873
3898
|
// Footer
|
|
3874
3899
|
console.log('');
|
|
@@ -3883,7 +3908,7 @@ function displayDigest(digest, metadata, sources, options, keyFacts, entities, e
|
|
|
3883
3908
|
}
|
|
3884
3909
|
console.log(chalk_1.default.gray(`Sources: ${metadata.sourcesUsed} memories | ` +
|
|
3885
3910
|
`${metadata.conversationsSpanned} conversations${timeLabel}`));
|
|
3886
|
-
console.log(chalk_1.default.gray(`Format: ${metadata.format} | Generated: ${metadata.generatedAt}`));
|
|
3911
|
+
console.log(chalk_1.default.gray(`Format: ${safeText(metadata.format)} | Generated: ${safeText(metadata.generatedAt)}`));
|
|
3887
3912
|
// Effective state breakdown
|
|
3888
3913
|
if (effectiveStateBreakdown) {
|
|
3889
3914
|
const esb = effectiveStateBreakdown;
|
|
@@ -3896,7 +3921,7 @@ function displayDigest(digest, metadata, sources, options, keyFacts, entities, e
|
|
|
3896
3921
|
console.log(chalk_1.default.gray('Source memories:'));
|
|
3897
3922
|
const chunks = [];
|
|
3898
3923
|
for (const s of sources) {
|
|
3899
|
-
chunks.push(`${s.memoryId} (${s.relevance.toFixed(2)})`);
|
|
3924
|
+
chunks.push(`${safeText(s.memoryId)} (${s.relevance.toFixed(2)})`);
|
|
3900
3925
|
}
|
|
3901
3926
|
// Print 3 per line
|
|
3902
3927
|
for (let i = 0; i < chunks.length; i += 3) {
|
|
@@ -4082,7 +4107,7 @@ function displayRecap(conversations, duration, health) {
|
|
|
4082
4107
|
// Get conversation title from first memory's first line
|
|
4083
4108
|
const firstMemory = memories[0]?.memory;
|
|
4084
4109
|
const lastMemory = memories[memories.length - 1]?.memory;
|
|
4085
|
-
const title = firstMemory?.content?.split('\n')[0]
|
|
4110
|
+
const title = safeText(firstMemory?.content?.split('\n')[0] ?? '').substring(0, 60) || 'Untitled';
|
|
4086
4111
|
// Format timestamps
|
|
4087
4112
|
const lastUpdated = formatTimelineDate(lastMemory?.eventTime || lastMemory?.createdAt);
|
|
4088
4113
|
// Get unique topics across all memories in conversation
|
|
@@ -4098,10 +4123,10 @@ function displayRecap(conversations, duration, health) {
|
|
|
4098
4123
|
console.log(chalk_1.default.bold(`## ${title}${title.length >= 60 ? '...' : ''}`));
|
|
4099
4124
|
console.log(chalk_1.default.gray(` ${memories.length} ${memories.length === 1 ? 'memory' : 'memories'} | ` +
|
|
4100
4125
|
`Last updated: ${lastUpdated} | ` +
|
|
4101
|
-
`${convId.substring(0, 20)}...`));
|
|
4126
|
+
`${safeText(convId).substring(0, 20)}...`));
|
|
4102
4127
|
// Show topics
|
|
4103
4128
|
if (allTopics.size > 0) {
|
|
4104
|
-
const topicsList = Array.from(allTopics).slice(0, 6).join(', ');
|
|
4129
|
+
const topicsList = safeText(Array.from(allTopics).slice(0, 6).join(', '));
|
|
4105
4130
|
const more = allTopics.size > 6 ? ` +${allTopics.size - 6} more` : '';
|
|
4106
4131
|
console.log(chalk_1.default.gray(` Topics: ${topicsList}${more}`));
|
|
4107
4132
|
}
|
|
@@ -4111,7 +4136,7 @@ function displayRecap(conversations, duration, health) {
|
|
|
4111
4136
|
const m = result.memory;
|
|
4112
4137
|
const state = m.effectiveState || 'current';
|
|
4113
4138
|
const stateIcon = state === 'superseded' ? chalk_1.default.gray('○') : chalk_1.default.green('●');
|
|
4114
|
-
const firstLine = m.content?.split('\n')[0]
|
|
4139
|
+
const firstLine = safeText(m.content?.split('\n')[0] ?? '').substring(0, 70);
|
|
4115
4140
|
console.log(` ${stateIcon} ${firstLine}${firstLine.length >= 70 ? '...' : ''}`);
|
|
4116
4141
|
}
|
|
4117
4142
|
if (memories.length > 5) {
|
|
@@ -4165,7 +4190,7 @@ function extractReferences(memories) {
|
|
|
4165
4190
|
* Display search results grouped by conversation
|
|
4166
4191
|
*/
|
|
4167
4192
|
function displayGroupedSearch(conversations, query, health) {
|
|
4168
|
-
console.log(chalk_1.default.cyan(`\n🔍 Search Results for "${query}" (grouped by conversation)`));
|
|
4193
|
+
console.log(chalk_1.default.cyan(`\n🔍 Search Results for "${safeText(query)}" (grouped by conversation)`));
|
|
4169
4194
|
const groupedMarker = (0, renderable_retrieval_1.degradationSummaryLine)(health);
|
|
4170
4195
|
if (groupedMarker) {
|
|
4171
4196
|
console.log(chalk_1.default.yellow(groupedMarker));
|
|
@@ -4183,7 +4208,7 @@ function displayGroupedSearch(conversations, query, health) {
|
|
|
4183
4208
|
// Get conversation title from first memory's first line
|
|
4184
4209
|
const firstMemory = memories[0]?.memory;
|
|
4185
4210
|
const lastMemory = memories[memories.length - 1]?.memory;
|
|
4186
|
-
const title = firstMemory?.content?.split('\n')[0]
|
|
4211
|
+
const title = safeText(firstMemory?.content?.split('\n')[0] ?? '').substring(0, 60) || 'Untitled';
|
|
4187
4212
|
// Format timestamps
|
|
4188
4213
|
const lastUpdated = formatTimelineDate(lastMemory?.eventTime || lastMemory?.createdAt);
|
|
4189
4214
|
// Get unique topics across all memories in conversation
|
|
@@ -4197,10 +4222,10 @@ function displayGroupedSearch(conversations, query, health) {
|
|
|
4197
4222
|
console.log(chalk_1.default.bold(`## ${title}${title.length >= 60 ? '...' : ''}`));
|
|
4198
4223
|
console.log(chalk_1.default.gray(` ${memories.length} ${memories.length === 1 ? 'match' : 'matches'} | ` +
|
|
4199
4224
|
`Last updated: ${lastUpdated} | ` +
|
|
4200
|
-
`${convId.substring(0, 20)}...`));
|
|
4225
|
+
`${safeText(convId).substring(0, 20)}...`));
|
|
4201
4226
|
// Show topics
|
|
4202
4227
|
if (allTopics.size > 0) {
|
|
4203
|
-
const topicsList = Array.from(allTopics).slice(0, 6).join(', ');
|
|
4228
|
+
const topicsList = safeText(Array.from(allTopics).slice(0, 6).join(', '));
|
|
4204
4229
|
const more = allTopics.size > 6 ? ` +${allTopics.size - 6} more` : '';
|
|
4205
4230
|
console.log(chalk_1.default.gray(` Topics: ${topicsList}${more}`));
|
|
4206
4231
|
}
|
|
@@ -4211,7 +4236,7 @@ function displayGroupedSearch(conversations, query, health) {
|
|
|
4211
4236
|
const score = result.score ? `[${result.score.toFixed(2)}]` : '';
|
|
4212
4237
|
const state = m.effectiveState || 'current';
|
|
4213
4238
|
const stateIcon = state === 'superseded' ? chalk_1.default.gray('○') : chalk_1.default.green('●');
|
|
4214
|
-
const firstLine = m.content?.split('\n')[0]
|
|
4239
|
+
const firstLine = safeText(m.content?.split('\n')[0] ?? '').substring(0, 65);
|
|
4215
4240
|
console.log(` ${stateIcon} ${chalk_1.default.gray(score)} ${firstLine}${firstLine.length >= 65 ? '...' : ''}`);
|
|
4216
4241
|
}
|
|
4217
4242
|
if (memories.length > 5) {
|
|
@@ -4288,9 +4313,9 @@ function registerBuildContextCommand(memories) {
|
|
|
4288
4313
|
if (briefing.data.activeWork) {
|
|
4289
4314
|
const aw = briefing.data.activeWork;
|
|
4290
4315
|
console.log(chalk_1.default.yellow.bold('Active Work'));
|
|
4291
|
-
console.log(` You were working on: ${chalk_1.default.white(aw.title || '(untitled)')} (${chalk_1.default.gray(aw.conversationId)})`);
|
|
4316
|
+
console.log(` You were working on: ${chalk_1.default.white(safeText(aw.title || '(untitled)'))} (${chalk_1.default.gray(safeText(aw.conversationId))})`);
|
|
4292
4317
|
if (aw.lastMemory?.summary) {
|
|
4293
|
-
console.log(` Last checkpoint: ${chalk_1.default.italic(`"${aw.lastMemory.summary}"`)}`);
|
|
4318
|
+
console.log(` Last checkpoint: ${chalk_1.default.italic(`"${safeText(aw.lastMemory.summary)}"`)}`);
|
|
4294
4319
|
}
|
|
4295
4320
|
console.log('');
|
|
4296
4321
|
}
|
|
@@ -4298,7 +4323,7 @@ function registerBuildContextCommand(memories) {
|
|
|
4298
4323
|
if (briefing.data.relevantFacts?.length) {
|
|
4299
4324
|
console.log(chalk_1.default.cyan.bold('Key Facts'));
|
|
4300
4325
|
for (const f of briefing.data.relevantFacts) {
|
|
4301
|
-
console.log(` ${chalk_1.default.gray('•')} ${f.subject} ${f.predicate} ${f.object}`);
|
|
4326
|
+
console.log(` ${chalk_1.default.gray('•')} ${safeText(f.subject)} ${safeText(f.predicate)} ${safeText(f.object)}`);
|
|
4302
4327
|
}
|
|
4303
4328
|
console.log('');
|
|
4304
4329
|
}
|
|
@@ -4306,7 +4331,7 @@ function registerBuildContextCommand(memories) {
|
|
|
4306
4331
|
if (briefing.data.gotchas?.length) {
|
|
4307
4332
|
console.log(chalk_1.default.red.bold('Gotchas'));
|
|
4308
4333
|
for (const g of briefing.data.gotchas) {
|
|
4309
|
-
console.log(` ${chalk_1.default.red('⚠')} ${chalk_1.default.bold(g.fact)} ${chalk_1.default.gray(`(${g.sourceCount} sources)`)}`);
|
|
4334
|
+
console.log(` ${chalk_1.default.red('⚠')} ${chalk_1.default.bold(safeText(g.fact))} ${chalk_1.default.gray(`(${safeText(g.sourceCount)} sources)`)}`);
|
|
4310
4335
|
}
|
|
4311
4336
|
console.log('');
|
|
4312
4337
|
}
|
|
@@ -4316,7 +4341,7 @@ function registerBuildContextCommand(memories) {
|
|
|
4316
4341
|
console.log(chalk_1.default.green.bold(`Recent Activity (last ${hours}h)`));
|
|
4317
4342
|
for (const a of briefing.data.recentActivity) {
|
|
4318
4343
|
const date = a.date ? (0, date_utils_1.formatApiDate)(a.date) : '';
|
|
4319
|
-
console.log(` ${chalk_1.default.gray('•')} ${a.summary} ${chalk_1.default.gray(`(${date})`)}`);
|
|
4344
|
+
console.log(` ${chalk_1.default.gray('•')} ${safeText(a.summary)} ${chalk_1.default.gray(`(${date})`)}`);
|
|
4320
4345
|
}
|
|
4321
4346
|
console.log('');
|
|
4322
4347
|
}
|
|
@@ -4325,13 +4350,13 @@ function registerBuildContextCommand(memories) {
|
|
|
4325
4350
|
console.log(chalk_1.default.magenta.bold('Relevant Patterns'));
|
|
4326
4351
|
for (const p of briefing.data.relatedPatterns) {
|
|
4327
4352
|
const conf = p.confidence != null ? chalk_1.default.gray(` (${(p.confidence * 100).toFixed(0)}%)`) : '';
|
|
4328
|
-
console.log(` ${chalk_1.default.gray('•')} ${p.pattern}${conf}`);
|
|
4353
|
+
console.log(` ${chalk_1.default.gray('•')} ${safeText(p.pattern)}${conf}`);
|
|
4329
4354
|
}
|
|
4330
4355
|
console.log('');
|
|
4331
4356
|
}
|
|
4332
4357
|
// Meta
|
|
4333
4358
|
if (briefing.data.meta?.contextTerms?.length) {
|
|
4334
|
-
console.log(chalk_1.default.gray(`Search terms: ${briefing.data.meta.contextTerms.join(', ')}`));
|
|
4359
|
+
console.log(chalk_1.default.gray(`Search terms: ${safeText(briefing.data.meta.contextTerms.join(', '))}`));
|
|
4335
4360
|
}
|
|
4336
4361
|
}
|
|
4337
4362
|
catch (error) {
|
|
@@ -4390,12 +4415,12 @@ function registerBuildContextCommand(memories) {
|
|
|
4390
4415
|
if (fmt === 'csv') {
|
|
4391
4416
|
console.log('bucket,count');
|
|
4392
4417
|
for (const row of result.data) {
|
|
4393
|
-
console.log(`${row.bucket},${row.count}`);
|
|
4418
|
+
console.log(`${csvField(safeText(row.bucket))},${row.count}`);
|
|
4394
4419
|
}
|
|
4395
4420
|
return;
|
|
4396
4421
|
}
|
|
4397
4422
|
// Table (bar chart) output
|
|
4398
|
-
const groupBy = result.groupBy;
|
|
4423
|
+
const groupBy = safeText(result.groupBy);
|
|
4399
4424
|
console.log('');
|
|
4400
4425
|
console.log(chalk_1.default.cyan.bold(`Memories by ${groupBy}`));
|
|
4401
4426
|
console.log(chalk_1.default.gray('─'.repeat(60)));
|
|
@@ -4408,7 +4433,7 @@ function registerBuildContextCommand(memories) {
|
|
|
4408
4433
|
for (const row of result.data) {
|
|
4409
4434
|
const barLen = maxCount > 0 ? Math.round((row.count / maxCount) * BAR_WIDTH) : 0;
|
|
4410
4435
|
const bar = chalk_1.default.blue('\u2588'.repeat(barLen));
|
|
4411
|
-
const label = row.bucket.padEnd(12);
|
|
4436
|
+
const label = safeText(row.bucket).padEnd(12);
|
|
4412
4437
|
const countStr = String(row.count).padStart(5);
|
|
4413
4438
|
console.log(` ${label} ${countStr} ${bar}`);
|
|
4414
4439
|
}
|
|
@@ -4416,7 +4441,7 @@ function registerBuildContextCommand(memories) {
|
|
|
4416
4441
|
console.log(chalk_1.default.bold(`Total: ${result.total} memories across ${result.data.length} active ${groupBy}s`));
|
|
4417
4442
|
if (groupBy !== 'topic' && result.data.length > 0) {
|
|
4418
4443
|
const peak = result.data.reduce((a, b) => (a.count >= b.count ? a : b));
|
|
4419
|
-
console.log(chalk_1.default.gray(`Peak ${groupBy}: ${peak.bucket} (${peak.count})`));
|
|
4444
|
+
console.log(chalk_1.default.gray(`Peak ${safeText(groupBy)}: ${safeText(peak.bucket)} (${peak.count})`));
|
|
4420
4445
|
}
|
|
4421
4446
|
}
|
|
4422
4447
|
if (result.filters.after || result.filters.before || result.filters.topic) {
|
|
@@ -4427,7 +4452,7 @@ function registerBuildContextCommand(memories) {
|
|
|
4427
4452
|
parts.push(`before ${result.filters.before}`);
|
|
4428
4453
|
if (result.filters.topic)
|
|
4429
4454
|
parts.push(`topic=${result.filters.topic}`);
|
|
4430
|
-
console.log(chalk_1.default.gray(`Filters: ${parts.join(', ')}`));
|
|
4455
|
+
console.log(chalk_1.default.gray(`Filters: ${safeText(parts.join(', '))}`));
|
|
4431
4456
|
}
|
|
4432
4457
|
}
|
|
4433
4458
|
catch (error) {
|