@crewx/memory 0.1.23-rc.19 → 0.1.23-rc.191
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/cli.d.ts +1 -1
- package/dist/cli.js +3 -340
- package/dist/src/engine.d.ts +25 -1
- package/dist/src/engine.js +94 -1009
- package/dist/src/mindmap.d.ts +1 -1
- package/dist/src/mindmap.js +26 -526
- package/dist/src/parser.d.ts +1 -1
- package/dist/src/parser.js +1 -7
- package/dist/src/types.d.ts +1 -1
- package/dist/src/types.js +1 -15
- package/package.json +4 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/src/engine.d.ts.map +0 -1
- package/dist/src/engine.js.map +0 -1
- package/dist/src/mindmap.d.ts.map +0 -1
- package/dist/src/mindmap.js.map +0 -1
- package/dist/src/parser.d.ts.map +0 -1
- package/dist/src/parser.js.map +0 -1
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/types.js.map +0 -1
package/dist/src/mindmap.d.ts
CHANGED
package/dist/src/mindmap.js
CHANGED
|
@@ -1,136 +1,10 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.MindmapEngine = void 0;
|
|
7
|
-
exports.loadAllEntries = loadAllEntries;
|
|
8
|
-
exports.buildGraph = buildGraph;
|
|
9
|
-
exports.saveGraph = saveGraph;
|
|
10
|
-
exports.loadGraph = loadGraph;
|
|
11
|
-
exports.generateHtml = generateHtml;
|
|
12
|
-
exports.filterGraphByPeriod = filterGraphByPeriod;
|
|
13
|
-
exports.renderMermaid = renderMermaid;
|
|
14
|
-
exports.renderText = renderText;
|
|
15
|
-
const fs_1 = __importDefault(require("fs"));
|
|
16
|
-
const path_1 = __importDefault(require("path"));
|
|
17
|
-
const child_process_1 = require("child_process");
|
|
18
|
-
const parser_1 = require("./parser");
|
|
19
|
-
const knowledge_core_1 = require("@crewx/knowledge-core");
|
|
20
|
-
const MEMORY_SHORT_TERM_HOURS = 24;
|
|
21
|
-
const MEMORY_SUMMARY_DAYS = 7;
|
|
22
|
-
const MEMORY_RECENT_DAYS = 30;
|
|
23
|
-
const PERIOD_CONFIG = {
|
|
24
|
-
stm: {
|
|
25
|
-
label: `STM ${MEMORY_SHORT_TERM_HOURS}h`,
|
|
26
|
-
ms: MEMORY_SHORT_TERM_HOURS * 60 * 60 * 1000,
|
|
27
|
-
},
|
|
28
|
-
mtm: {
|
|
29
|
-
label: `MTM ${MEMORY_SUMMARY_DAYS}d`,
|
|
30
|
-
ms: MEMORY_SUMMARY_DAYS * 24 * 60 * 60 * 1000,
|
|
31
|
-
},
|
|
32
|
-
ltm: {
|
|
33
|
-
label: `LTM ${MEMORY_RECENT_DAYS}d`,
|
|
34
|
-
ms: MEMORY_RECENT_DAYS * 24 * 60 * 60 * 1000,
|
|
35
|
-
},
|
|
36
|
-
};
|
|
37
|
-
const DEFAULT_COLORS = [
|
|
38
|
-
'#6366f1', '#8b5cf6', '#ec4899', '#f43f5e', '#f97316',
|
|
39
|
-
'#eab308', '#22c55e', '#14b8a6', '#06b6d4', '#3b82f6',
|
|
40
|
-
];
|
|
41
|
-
function loadAllEntries(entriesDir) {
|
|
42
|
-
if (!fs_1.default.existsSync(entriesDir))
|
|
43
|
-
return [];
|
|
44
|
-
const files = fs_1.default.readdirSync(entriesDir).filter(f => f.endsWith('.md'));
|
|
45
|
-
const entries = [];
|
|
46
|
-
for (const file of files) {
|
|
47
|
-
const raw = fs_1.default.readFileSync(path_1.default.join(entriesDir, file), 'utf-8');
|
|
48
|
-
const { data, content } = (0, parser_1.parseFrontmatter)(raw);
|
|
49
|
-
entries.push({ file, content, ...data });
|
|
50
|
-
}
|
|
51
|
-
return entries;
|
|
52
|
-
}
|
|
53
|
-
function buildGraph(entriesDir, options = {}) {
|
|
54
|
-
const { edgeThreshold = 0.3, includeSameDay = false, } = options;
|
|
55
|
-
const entries = loadAllEntries(entriesDir);
|
|
56
|
-
if (entries.length === 0) {
|
|
57
|
-
return null;
|
|
58
|
-
}
|
|
59
|
-
const kcEntries = entries.map(e => ({
|
|
60
|
-
id: e.id,
|
|
61
|
-
type: e['type'] || 'memory',
|
|
62
|
-
category: e.category || 'general',
|
|
63
|
-
tags: e.tags || [],
|
|
64
|
-
date: e.date || '',
|
|
65
|
-
summary: e.summary || '',
|
|
66
|
-
body: e.content || '',
|
|
67
|
-
}));
|
|
68
|
-
const coreGraph = (0, knowledge_core_1.buildGraph)(kcEntries, { edgeThreshold, includeSameDay });
|
|
69
|
-
return {
|
|
70
|
-
nodes: coreGraph.nodes.map(n => ({
|
|
71
|
-
...n,
|
|
72
|
-
important: entries.find(e => e.id === n.id)?.important,
|
|
73
|
-
})),
|
|
74
|
-
edges: coreGraph.edges,
|
|
75
|
-
stats: coreGraph.stats,
|
|
76
|
-
updated: new Date().toISOString(),
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
function saveGraph(outputPath, graph) {
|
|
80
|
-
graph.updated = new Date().toISOString();
|
|
81
|
-
fs_1.default.writeFileSync(outputPath, JSON.stringify(graph, null, 2), 'utf-8');
|
|
82
|
-
}
|
|
83
|
-
function loadGraph(inputPath) {
|
|
84
|
-
if (!fs_1.default.existsSync(inputPath)) {
|
|
85
|
-
return { nodes: [], edges: [], stats: { nodeCount: 0, edgeCount: 0 }, updated: null };
|
|
86
|
-
}
|
|
87
|
-
return JSON.parse(fs_1.default.readFileSync(inputPath, 'utf-8'));
|
|
88
|
-
}
|
|
89
|
-
function generateHtml(graphs, options = {}) {
|
|
90
|
-
const { colors = DEFAULT_COLORS, title = 'Memory Graph' } = options;
|
|
91
|
-
if (Object.keys(graphs).length === 0) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
const agentData = {};
|
|
95
|
-
for (const [agentId, graph] of Object.entries(graphs)) {
|
|
96
|
-
if (!graph || !graph.nodes || graph.nodes.length === 0) {
|
|
97
|
-
continue;
|
|
98
|
-
}
|
|
99
|
-
const topics = [...new Set(graph.nodes.map(n => (n.tags?.[0]) || 'general'))];
|
|
100
|
-
const topicColors = {};
|
|
101
|
-
topics.forEach((topic, i) => {
|
|
102
|
-
topicColors[topic] = colors[i % colors.length];
|
|
103
|
-
});
|
|
104
|
-
const nodes = graph.nodes.map(n => {
|
|
105
|
-
const summary = n.summary ? String(n.summary) : (n.id ? String(n.id) : 'Unknown');
|
|
106
|
-
const primaryTag = (n.tags?.[0]) || 'general';
|
|
107
|
-
return {
|
|
108
|
-
id: n.id || 'unknown',
|
|
109
|
-
label: summary.slice(0, 40),
|
|
110
|
-
fullLabel: summary,
|
|
111
|
-
topic: primaryTag,
|
|
112
|
-
date: n.date || '-',
|
|
113
|
-
color: topicColors[primaryTag],
|
|
114
|
-
};
|
|
115
|
-
});
|
|
116
|
-
const links = graph.edges.map(e => ({
|
|
117
|
-
source: e.from,
|
|
118
|
-
target: e.to,
|
|
119
|
-
weight: e.weight,
|
|
120
|
-
type: e.type,
|
|
121
|
-
}));
|
|
122
|
-
agentData[agentId] = { nodes, links, topics, topicColors, updated: graph.updated };
|
|
123
|
-
}
|
|
124
|
-
const agentOptions = Object.keys(agentData)
|
|
125
|
-
.map(agentId => `<option value="${agentId}">${agentId}</option>`)
|
|
126
|
-
.join('');
|
|
127
|
-
return `<!DOCTYPE html>
|
|
128
|
-
<html lang="ko">
|
|
1
|
+
"use strict";var S=exports&&exports.__importDefault||function(a){return a&&a.__esModule?a:{"default":a}};Object.defineProperty(exports,"__esModule",{value:true});exports.MindmapEngine=void 0;exports.loadAllEntries=w;exports.buildGraph=k;exports.saveGraph=b;exports.loadGraph=f;exports.generateHtml=E;exports.filterGraphByPeriod=P;exports.renderMermaid=T;exports.renderText=N;const g=S(require("fs"));const p=S(require("path"));const x=require("child_process");const O=require("./parser");const j=require("@crewx/knowledge-core");const $=24;const M=7;const D=30;const L={stm:{label:`STM ${$}h`,ms:$*60*60*1e3},mtm:{label:`MTM ${M}d`,ms:M*24*60*60*1e3},ltm:{label:`LTM ${D}d`,ms:D*24*60*60*1e3}};const A=["#6366f1","#8b5cf6","#ec4899","#f43f5e","#f97316","#eab308","#22c55e","#14b8a6","#06b6d4","#3b82f6"];function w(a){if(!g.default.existsSync(a))return[];const t=g.default.readdirSync(a).filter(i=>i.endsWith(".md"));const o=[];for(const i of t){const n=g.default.readFileSync(p.default.join(a,i),"utf-8");const{data:r,content:s}=(0,O.parseFrontmatter)(n);o.push({file:i,content:s,...r})}return o}function k(a,t={}){const{edgeThreshold:o=.3,includeSameDay:i=false}=t;const n=w(a);if(n.length===0){return null}const r=n.map(e=>({id:e.id,type:e["type"]||"memory",category:e.category||"general",tags:e.tags||[],date:e.date||"",summary:e.summary||"",body:e.content||""}));const s=(0,j.buildGraph)(r,{edgeThreshold:o,includeSameDay:i});return{nodes:s.nodes.map(e=>({...e,important:n.find(l=>l.id===e.id)?.important})),edges:s.edges,stats:s.stats,updated:new Date().toISOString()}}function b(a,t){t.updated=new Date().toISOString();g.default.writeFileSync(a,JSON.stringify(t,null,2),"utf-8")}function f(a){if(!g.default.existsSync(a)){return{nodes:[],edges:[],stats:{nodeCount:0,edgeCount:0},updated:null}}return JSON.parse(g.default.readFileSync(a,"utf-8"))}function E(a,t={}){const{colors:o=A,title:i="Memory Graph"}=t;if(Object.keys(a).length===0){return null}const n={};for(const[s,e]of Object.entries(a)){if(!e||!e.nodes||e.nodes.length===0){continue}const l=[...new Set(e.nodes.map(c=>c.tags?.[0]||"general"))];const d={};l.forEach((c,m)=>{d[c]=o[m%o.length]});const u=e.nodes.map(c=>{const m=c.summary?String(c.summary):c.id?String(c.id):"Unknown";const v=c.tags?.[0]||"general";return{id:c.id||"unknown",label:m.slice(0,40),fullLabel:m,topic:v,date:c.date||"-",color:d[v]}});const h=e.edges.map(c=>({source:c.from,target:c.to,weight:c.weight,type:c.type}));n[s]={nodes:u,links:h,topics:l,topicColors:d,updated:e.updated}}const r=Object.keys(n).map(s=>`<option value="${s}">${s}</option>`).join("");return`<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
129
3
|
<head>
|
|
130
4
|
<meta charset="UTF-8">
|
|
131
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
132
|
-
<title>${
|
|
133
|
-
<script src="https://d3js.org/d3.v7.min.js"
|
|
6
|
+
<title>${i}</title>
|
|
7
|
+
<script src="https://d3js.org/d3.v7.min.js"><\/script>
|
|
134
8
|
<style>
|
|
135
9
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
136
10
|
body {
|
|
@@ -236,8 +110,8 @@ function generateHtml(graphs, options = {}) {
|
|
|
236
110
|
<div id="graph"></div>
|
|
237
111
|
|
|
238
112
|
<div class="controls">
|
|
239
|
-
<h3
|
|
240
|
-
<select id="agentSelect">${
|
|
113
|
+
<h3>\u{1F4CA} ${i}</h3>
|
|
114
|
+
<select id="agentSelect">${r}</select>
|
|
241
115
|
<select id="periodSelect">
|
|
242
116
|
<option value="all">All</option>
|
|
243
117
|
<option value="stm">STM (24h)</option>
|
|
@@ -253,7 +127,7 @@ function generateHtml(graphs, options = {}) {
|
|
|
253
127
|
<div class="tooltip" style="display:none"></div>
|
|
254
128
|
|
|
255
129
|
<script>
|
|
256
|
-
const agentData = ${JSON.stringify(
|
|
130
|
+
const agentData = ${JSON.stringify(n)};
|
|
257
131
|
|
|
258
132
|
const urlParams = new URLSearchParams(window.location.search);
|
|
259
133
|
const agentFromUrl = urlParams.get('agent');
|
|
@@ -317,7 +191,7 @@ function generateHtml(graphs, options = {}) {
|
|
|
317
191
|
const items = topics.map(t =>
|
|
318
192
|
'<div class="legend-item"><div class="legend-color" style="background:' + (colors[t] || '#666') + '"></div><span>' + t + '</span></div>'
|
|
319
193
|
).join('');
|
|
320
|
-
document.getElementById('legend').innerHTML = '<h4
|
|
194
|
+
document.getElementById('legend').innerHTML = '<h4>topics</h4>' + items;
|
|
321
195
|
}
|
|
322
196
|
|
|
323
197
|
function updateStats(data) {
|
|
@@ -328,12 +202,12 @@ function generateHtml(graphs, options = {}) {
|
|
|
328
202
|
ltm: 'LTM (30d)'
|
|
329
203
|
};
|
|
330
204
|
const periodLabel = periodLabels[currentPeriod] || 'All';
|
|
331
|
-
const periodText = currentPeriod === 'all' ? '' : (' |
|
|
205
|
+
const periodText = currentPeriod === 'all' ? '' : (' | Period: ' + periodLabel);
|
|
332
206
|
document.getElementById('stats').innerHTML =
|
|
333
|
-
'
|
|
334
|
-
'
|
|
335
|
-
'
|
|
336
|
-
'
|
|
207
|
+
'Agents: ' + currentAgent + ' | ' +
|
|
208
|
+
'Nodes: ' + data.nodes.length + ' | ' +
|
|
209
|
+
'Edges: ' + data.links.length + ' | ' +
|
|
210
|
+
'Updated: ' + (data.updated ? data.updated.slice(0, 10) : '-') +
|
|
337
211
|
periodText;
|
|
338
212
|
}
|
|
339
213
|
|
|
@@ -390,7 +264,7 @@ function generateHtml(graphs, options = {}) {
|
|
|
390
264
|
tooltip.style('display', 'block')
|
|
391
265
|
.style('left', (event.pageX + 15) + 'px')
|
|
392
266
|
.style('top', (event.pageY - 10) + 'px')
|
|
393
|
-
.html('<div class="title">' + d.fullLabel + '</div><div class="meta">ID: ' + d.id + '<br
|
|
267
|
+
.html('<div class="title">' + d.fullLabel + '</div><div class="meta">ID: ' + d.id + '<br>topics: ' + d.topic + '<br>Date: ' + d.date + '</div>');
|
|
394
268
|
}).on('mouseout', () => {
|
|
395
269
|
tooltip.style('display', 'none');
|
|
396
270
|
});
|
|
@@ -449,390 +323,16 @@ function generateHtml(graphs, options = {}) {
|
|
|
449
323
|
initSVG();
|
|
450
324
|
renderGraph();
|
|
451
325
|
});
|
|
452
|
-
|
|
326
|
+
<\/script>
|
|
453
327
|
</body>
|
|
454
|
-
</html
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
}
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
return { graph, label: null, invalid: false };
|
|
466
|
-
}
|
|
467
|
-
const key = String(period).toLowerCase();
|
|
468
|
-
const config = PERIOD_CONFIG[key];
|
|
469
|
-
if (!config) {
|
|
470
|
-
return { graph, label: null, invalid: true };
|
|
471
|
-
}
|
|
472
|
-
const cutoff = Date.now() - config.ms;
|
|
473
|
-
const nodes = (graph.nodes || []).filter(node => {
|
|
474
|
-
const date = parseDateForFilter(node.date);
|
|
475
|
-
return date && date.getTime() >= cutoff;
|
|
476
|
-
});
|
|
477
|
-
const nodeIds = new Set(nodes.map(n => n.id));
|
|
478
|
-
const edges = (graph.edges || []).filter(e => nodeIds.has(e.from) && nodeIds.has(e.to));
|
|
479
|
-
return {
|
|
480
|
-
graph: {
|
|
481
|
-
...graph,
|
|
482
|
-
nodes,
|
|
483
|
-
edges,
|
|
484
|
-
stats: { nodeCount: nodes.length, edgeCount: edges.length },
|
|
485
|
-
},
|
|
486
|
-
label: config.label,
|
|
487
|
-
invalid: false,
|
|
488
|
-
};
|
|
489
|
-
}
|
|
490
|
-
function truncateLabel(value, limit = 30) {
|
|
491
|
-
const text = value ? String(value) : '';
|
|
492
|
-
if (text.length <= limit)
|
|
493
|
-
return text;
|
|
494
|
-
return text.slice(0, limit);
|
|
495
|
-
}
|
|
496
|
-
function escapeMermaidLabel(value) {
|
|
497
|
-
return String(value)
|
|
498
|
-
.replace(/\\/g, '\\\\')
|
|
499
|
-
.replace(/"/g, '\\"')
|
|
500
|
-
.replace(/\r?\n/g, ' ');
|
|
501
|
-
}
|
|
502
|
-
function sanitizeMermaidId(value) {
|
|
503
|
-
return String(value || '').replace(/[^a-zA-Z0-9_-]/g, '_');
|
|
504
|
-
}
|
|
505
|
-
function mergeImportantFlags(graph, entries) {
|
|
506
|
-
if (!entries || entries.length === 0)
|
|
507
|
-
return graph;
|
|
508
|
-
const importantMap = new Map();
|
|
509
|
-
for (const entry of entries) {
|
|
510
|
-
if (entry && entry.id) {
|
|
511
|
-
importantMap.set(entry.id, Boolean(entry.important));
|
|
512
|
-
}
|
|
513
|
-
}
|
|
514
|
-
if (importantMap.size === 0)
|
|
515
|
-
return graph;
|
|
516
|
-
const nodes = (graph.nodes || []).map(node => {
|
|
517
|
-
if (importantMap.has(node.id)) {
|
|
518
|
-
return { ...node, important: importantMap.get(node.id) };
|
|
519
|
-
}
|
|
520
|
-
return node;
|
|
521
|
-
});
|
|
522
|
-
return { ...graph, nodes };
|
|
523
|
-
}
|
|
524
|
-
function renderMermaid(viewGraph) {
|
|
525
|
-
const lines = [];
|
|
526
|
-
lines.push('```mermaid');
|
|
527
|
-
lines.push('graph LR');
|
|
528
|
-
const byTag = {};
|
|
529
|
-
for (const node of viewGraph.nodes || []) {
|
|
530
|
-
const tag = (node.tags?.[0]) || 'general';
|
|
531
|
-
if (!byTag[tag])
|
|
532
|
-
byTag[tag] = [];
|
|
533
|
-
byTag[tag].push(node);
|
|
534
|
-
}
|
|
535
|
-
const tagKeys = Object.keys(byTag).sort((a, b) => a.localeCompare(b));
|
|
536
|
-
for (const topic of tagKeys) {
|
|
537
|
-
const topicId = sanitizeMermaidId(topic || 'general');
|
|
538
|
-
lines.push(` subgraph ${topicId}`);
|
|
539
|
-
const nodes = byTag[topic].slice().sort((a, b) => {
|
|
540
|
-
const aId = String(a.id || '');
|
|
541
|
-
const bId = String(b.id || '');
|
|
542
|
-
return aId.localeCompare(bId);
|
|
543
|
-
});
|
|
544
|
-
for (const node of nodes) {
|
|
545
|
-
const baseLabel = truncateLabel(node.summary || node.id || 'Unknown', 30);
|
|
546
|
-
const label = node.important ? `⭐ ${baseLabel}` : baseLabel;
|
|
547
|
-
const safeLabel = escapeMermaidLabel(label);
|
|
548
|
-
const nodeId = sanitizeMermaidId(node.id);
|
|
549
|
-
lines.push(` ${nodeId}["${safeLabel}"]`);
|
|
550
|
-
}
|
|
551
|
-
lines.push(' end');
|
|
552
|
-
}
|
|
553
|
-
const edges = (viewGraph.edges || []).filter(edge => Number(edge.weight) >= 0.5);
|
|
554
|
-
for (const edge of edges) {
|
|
555
|
-
const fromId = sanitizeMermaidId(edge.from);
|
|
556
|
-
const toId = sanitizeMermaidId(edge.to);
|
|
557
|
-
const weight = Number.isFinite(edge.weight) ? edge.weight : Number(edge.weight);
|
|
558
|
-
const weightLabel = Number.isFinite(weight) ? weight : edge.weight;
|
|
559
|
-
lines.push(` ${fromId} -->|${weightLabel}| ${toId}`);
|
|
560
|
-
}
|
|
561
|
-
lines.push('```');
|
|
562
|
-
return lines.join('\n');
|
|
563
|
-
}
|
|
564
|
-
function renderText(viewGraph, agentId, filtered) {
|
|
565
|
-
console.log(`# ${agentId} 연결 그래프\n`);
|
|
566
|
-
if (filtered.label && !filtered.invalid) {
|
|
567
|
-
console.log(`> (기간 필터: ${filtered.label})`);
|
|
568
|
-
}
|
|
569
|
-
console.log(`> 최종 업데이트: ${viewGraph.updated || '-'}`);
|
|
570
|
-
console.log(`> 노드: ${viewGraph.nodes.length}개 | 엣지: ${viewGraph.edges.length}개\n`);
|
|
571
|
-
if (viewGraph.nodes.length === 0) {
|
|
572
|
-
console.log('해당 기간에 해당하는 노드가 없습니다.');
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
const byTag = {};
|
|
576
|
-
for (const node of viewGraph.nodes) {
|
|
577
|
-
const tag = (node.tags?.[0]) || 'general';
|
|
578
|
-
if (!byTag[tag])
|
|
579
|
-
byTag[tag] = [];
|
|
580
|
-
byTag[tag].push(node);
|
|
581
|
-
}
|
|
582
|
-
console.log(`## 태그별 클러스터\n`);
|
|
583
|
-
for (const [topic, nodes] of Object.entries(byTag).sort((a, b) => b[1].length - a[1].length)) {
|
|
584
|
-
console.log(`### ${topic} (${nodes.length}개)`);
|
|
585
|
-
for (const node of nodes.slice(0, 5)) {
|
|
586
|
-
const connectionCount = viewGraph.edges.filter(e => e.from === node.id || e.to === node.id).length;
|
|
587
|
-
console.log(`- [${node.id}] ${node.summary} (연결: ${connectionCount})`);
|
|
588
|
-
}
|
|
589
|
-
if (nodes.length > 5) {
|
|
590
|
-
console.log(`- ... 외 ${nodes.length - 5}개`);
|
|
591
|
-
}
|
|
592
|
-
console.log('');
|
|
593
|
-
}
|
|
594
|
-
const connectionCounts = {};
|
|
595
|
-
for (const edge of viewGraph.edges) {
|
|
596
|
-
connectionCounts[edge.from] = (connectionCounts[edge.from] || 0) + 1;
|
|
597
|
-
connectionCounts[edge.to] = (connectionCounts[edge.to] || 0) + 1;
|
|
598
|
-
}
|
|
599
|
-
const hubs = Object.entries(connectionCounts)
|
|
600
|
-
.sort((a, b) => b[1] - a[1])
|
|
601
|
-
.slice(0, 5);
|
|
602
|
-
if (hubs.length > 0) {
|
|
603
|
-
console.log(`## 허브 노드 (연결 많은 기억)\n`);
|
|
604
|
-
const nodeMap = {};
|
|
605
|
-
viewGraph.nodes.forEach(n => (nodeMap[n.id] = n));
|
|
606
|
-
for (const [id, count] of hubs) {
|
|
607
|
-
const node = nodeMap[id];
|
|
608
|
-
if (node) {
|
|
609
|
-
console.log(`- [${id}] ${node.summary} - ${count}개 연결`);
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
}
|
|
613
|
-
}
|
|
614
|
-
class MindmapEngine {
|
|
615
|
-
constructor(dataDir) {
|
|
616
|
-
this.dataDir = dataDir;
|
|
617
|
-
}
|
|
618
|
-
getAgentDir(agentId) {
|
|
619
|
-
return path_1.default.join(this.dataDir, agentId);
|
|
620
|
-
}
|
|
621
|
-
getEntriesDir(agentId) {
|
|
622
|
-
return path_1.default.join(this.getAgentDir(agentId), 'entries');
|
|
623
|
-
}
|
|
624
|
-
getGraphPath(agentId) {
|
|
625
|
-
return path_1.default.join(this.getAgentDir(agentId), 'graph.json');
|
|
626
|
-
}
|
|
627
|
-
getHtmlPath() {
|
|
628
|
-
return path_1.default.join(this.dataDir, 'mindmap.html');
|
|
629
|
-
}
|
|
630
|
-
build(agentId, options = {}) {
|
|
631
|
-
console.log(`🔨 ${agentId} 그래프 빌드 중...\n`);
|
|
632
|
-
const entriesDir = this.getEntriesDir(agentId);
|
|
633
|
-
const graph = buildGraph(entriesDir, { edgeThreshold: 0.3, ...options });
|
|
634
|
-
if (!graph) {
|
|
635
|
-
console.log('기억이 없습니다.');
|
|
636
|
-
return;
|
|
637
|
-
}
|
|
638
|
-
saveGraph(this.getGraphPath(agentId), graph);
|
|
639
|
-
console.log(`✅ 그래프 빌드 완료!`);
|
|
640
|
-
console.log(` 노드: ${graph.stats.nodeCount}개`);
|
|
641
|
-
console.log(` 엣지: ${graph.stats.edgeCount}개`);
|
|
642
|
-
console.log(` 파일: ${agentId}/graph.json`);
|
|
643
|
-
if (graph.edges.length > 0) {
|
|
644
|
-
console.log(`\n📊 주요 연결 (weight 상위 10개):`);
|
|
645
|
-
const topEdges = graph.edges.sort((a, b) => b.weight - a.weight).slice(0, 10);
|
|
646
|
-
const nodeMap = {};
|
|
647
|
-
graph.nodes.forEach(n => (nodeMap[n.id] = n.summary));
|
|
648
|
-
for (const edge of topEdges) {
|
|
649
|
-
const fromSummary = (nodeMap[edge.from] || edge.from).slice(0, 25);
|
|
650
|
-
const toSummary = (nodeMap[edge.to] || edge.to).slice(0, 25);
|
|
651
|
-
console.log(` [${edge.weight}] ${fromSummary}... ↔ ${toSummary}...`);
|
|
652
|
-
}
|
|
653
|
-
}
|
|
654
|
-
}
|
|
655
|
-
show(agentId, options = {}) {
|
|
656
|
-
const graph = loadGraph(this.getGraphPath(agentId));
|
|
657
|
-
if (!graph.nodes || graph.nodes.length === 0) {
|
|
658
|
-
console.log('그래프가 없습니다. 먼저 build 명령을 실행하세요.');
|
|
659
|
-
return;
|
|
660
|
-
}
|
|
661
|
-
const filtered = filterGraphByPeriod(graph, options.period);
|
|
662
|
-
if (filtered.invalid) {
|
|
663
|
-
console.log(`⚠️ 알 수 없는 period: ${options.period} (stm|mtm|ltm)`);
|
|
664
|
-
}
|
|
665
|
-
let viewGraph = filtered.invalid ? graph : filtered.graph;
|
|
666
|
-
const entries = loadAllEntries(this.getEntriesDir(agentId));
|
|
667
|
-
viewGraph = mergeImportantFlags(viewGraph, entries);
|
|
668
|
-
const format = normalizeFormatOption(options.format);
|
|
669
|
-
if (format === 'text') {
|
|
670
|
-
renderText(viewGraph, agentId, filtered);
|
|
671
|
-
return;
|
|
672
|
-
}
|
|
673
|
-
if (!viewGraph.nodes || viewGraph.nodes.length === 0) {
|
|
674
|
-
console.log('해당 기간에 해당하는 노드가 없습니다.');
|
|
675
|
-
return;
|
|
676
|
-
}
|
|
677
|
-
if (filtered.label && !filtered.invalid) {
|
|
678
|
-
console.log(`(기간 필터: ${filtered.label})`);
|
|
679
|
-
}
|
|
680
|
-
console.log(renderMermaid(viewGraph));
|
|
681
|
-
}
|
|
682
|
-
related(agentId, memoryId) {
|
|
683
|
-
const graph = loadGraph(this.getGraphPath(agentId));
|
|
684
|
-
if (!graph.nodes || graph.nodes.length === 0) {
|
|
685
|
-
console.log('그래프가 없습니다. 먼저 build 명령을 실행하세요.');
|
|
686
|
-
return;
|
|
687
|
-
}
|
|
688
|
-
const node = graph.nodes.find(n => n.id === memoryId);
|
|
689
|
-
if (!node) {
|
|
690
|
-
console.log(`ID '${memoryId}'를 찾을 수 없습니다.`);
|
|
691
|
-
return;
|
|
692
|
-
}
|
|
693
|
-
console.log(`## 🔗 [${memoryId}] ${node.summary}\n`);
|
|
694
|
-
console.log(`- 날짜: ${node.date || '-'}`);
|
|
695
|
-
console.log(`- 태그: ${(node.tags || []).join(', ') || '-'}\n`);
|
|
696
|
-
const connectedEdges = graph.edges.filter(e => e.from === memoryId || e.to === memoryId);
|
|
697
|
-
if (connectedEdges.length === 0) {
|
|
698
|
-
console.log('연결된 기억이 없습니다.');
|
|
699
|
-
return;
|
|
700
|
-
}
|
|
701
|
-
console.log(`### 연결된 기억 (${connectedEdges.length}개)\n`);
|
|
702
|
-
const nodeMap = {};
|
|
703
|
-
graph.nodes.forEach(n => (nodeMap[n.id] = n));
|
|
704
|
-
connectedEdges.sort((a, b) => b.weight - a.weight);
|
|
705
|
-
for (const edge of connectedEdges) {
|
|
706
|
-
const otherId = edge.from === memoryId ? edge.to : edge.from;
|
|
707
|
-
const otherNode = nodeMap[otherId];
|
|
708
|
-
if (otherNode) {
|
|
709
|
-
const reasons = edge.reasons.join(', ');
|
|
710
|
-
console.log(`[${edge.weight}] [${otherId}] ${otherNode.summary}`);
|
|
711
|
-
console.log(` └─ 연결 이유: ${reasons}`);
|
|
712
|
-
}
|
|
713
|
-
}
|
|
714
|
-
}
|
|
715
|
-
add(agentId, fromId, toId, type = 'manual') {
|
|
716
|
-
const graph = loadGraph(this.getGraphPath(agentId));
|
|
717
|
-
if (!graph.nodes || graph.nodes.length === 0) {
|
|
718
|
-
console.log('그래프가 없습니다. 먼저 build 명령을 실행하세요.');
|
|
719
|
-
return;
|
|
720
|
-
}
|
|
721
|
-
const fromNode = graph.nodes.find(n => n.id === fromId);
|
|
722
|
-
const toNode = graph.nodes.find(n => n.id === toId);
|
|
723
|
-
if (!fromNode) {
|
|
724
|
-
console.log(`ID '${fromId}'를 찾을 수 없습니다.`);
|
|
725
|
-
return;
|
|
726
|
-
}
|
|
727
|
-
if (!toNode) {
|
|
728
|
-
console.log(`ID '${toId}'를 찾을 수 없습니다.`);
|
|
729
|
-
return;
|
|
730
|
-
}
|
|
731
|
-
const existingEdge = graph.edges.find(e => (e.from === fromId && e.to === toId) || (e.from === toId && e.to === fromId));
|
|
732
|
-
if (existingEdge) {
|
|
733
|
-
console.log(`이미 연결되어 있습니다: weight ${existingEdge.weight}`);
|
|
734
|
-
return;
|
|
735
|
-
}
|
|
736
|
-
graph.edges.push({
|
|
737
|
-
from: fromId,
|
|
738
|
-
to: toId,
|
|
739
|
-
type,
|
|
740
|
-
weight: 1.0,
|
|
741
|
-
reasons: [type],
|
|
742
|
-
manual: true,
|
|
743
|
-
});
|
|
744
|
-
saveGraph(this.getGraphPath(agentId), graph);
|
|
745
|
-
console.log(`✅ 연결 추가 완료!`);
|
|
746
|
-
console.log(` ${(fromNode.summary || '').slice(0, 30)}...`);
|
|
747
|
-
console.log(` ↔`);
|
|
748
|
-
console.log(` ${(toNode.summary || '').slice(0, 30)}...`);
|
|
749
|
-
}
|
|
750
|
-
remove(agentId, fromId, toId) {
|
|
751
|
-
const graph = loadGraph(this.getGraphPath(agentId));
|
|
752
|
-
if (!graph.edges || graph.edges.length === 0) {
|
|
753
|
-
console.log('연결이 없습니다.');
|
|
754
|
-
return;
|
|
755
|
-
}
|
|
756
|
-
const edgeIndex = graph.edges.findIndex(e => (e.from === fromId && e.to === toId) || (e.from === toId && e.to === fromId));
|
|
757
|
-
if (edgeIndex === -1) {
|
|
758
|
-
console.log('해당 연결을 찾을 수 없습니다.');
|
|
759
|
-
return;
|
|
760
|
-
}
|
|
761
|
-
graph.edges.splice(edgeIndex, 1);
|
|
762
|
-
saveGraph(this.getGraphPath(agentId), graph);
|
|
763
|
-
console.log(`🗑️ 연결 제거 완료: ${fromId} ↔ ${toId}`);
|
|
764
|
-
}
|
|
765
|
-
html() {
|
|
766
|
-
if (!fs_1.default.existsSync(this.dataDir)) {
|
|
767
|
-
console.log('data 디렉토리가 없습니다.');
|
|
768
|
-
return;
|
|
769
|
-
}
|
|
770
|
-
const agentDirs = fs_1.default.readdirSync(this.dataDir).filter(name => {
|
|
771
|
-
const dirPath = path_1.default.join(this.dataDir, name);
|
|
772
|
-
try {
|
|
773
|
-
return fs_1.default.statSync(dirPath).isDirectory();
|
|
774
|
-
}
|
|
775
|
-
catch {
|
|
776
|
-
return false;
|
|
777
|
-
}
|
|
778
|
-
});
|
|
779
|
-
const agentGraphs = {};
|
|
780
|
-
let totalNodes = 0;
|
|
781
|
-
let totalEdges = 0;
|
|
782
|
-
for (const agentId of agentDirs) {
|
|
783
|
-
const graph = loadGraph(this.getGraphPath(agentId));
|
|
784
|
-
if (graph.nodes && graph.nodes.length > 0) {
|
|
785
|
-
agentGraphs[agentId] = graph;
|
|
786
|
-
totalNodes += graph.nodes.length;
|
|
787
|
-
totalEdges += graph.edges.length;
|
|
788
|
-
}
|
|
789
|
-
}
|
|
790
|
-
if (Object.keys(agentGraphs).length === 0) {
|
|
791
|
-
console.log('그래프가 없습니다. 먼저 build 명령을 실행하세요.');
|
|
792
|
-
return;
|
|
793
|
-
}
|
|
794
|
-
const htmlContent = generateHtml(agentGraphs, {
|
|
795
|
-
title: 'Memory Graph - All Agents',
|
|
796
|
-
});
|
|
797
|
-
if (!htmlContent) {
|
|
798
|
-
console.log('HTML 생성 실패');
|
|
799
|
-
return;
|
|
800
|
-
}
|
|
801
|
-
const htmlPath = this.getHtmlPath();
|
|
802
|
-
fs_1.default.writeFileSync(htmlPath, htmlContent, 'utf-8');
|
|
803
|
-
console.log(`✅ 공용 그래프 시각화 생성 완료!`);
|
|
804
|
-
console.log(` 파일: ${htmlPath}`);
|
|
805
|
-
console.log(` 에이전트: ${Object.keys(agentGraphs).length}개`);
|
|
806
|
-
console.log(` 전체 노드: ${totalNodes}개 | 전체 엣지: ${totalEdges}개`);
|
|
807
|
-
console.log(`\n브라우저에서 열기: open ${htmlPath}`);
|
|
808
|
-
}
|
|
809
|
-
open(agentId) {
|
|
810
|
-
const htmlPath = this.getHtmlPath();
|
|
811
|
-
if (!fs_1.default.existsSync(htmlPath)) {
|
|
812
|
-
console.log('mindmap.html이 없습니다. 먼저 html 명령을 실행하세요.');
|
|
813
|
-
return;
|
|
814
|
-
}
|
|
815
|
-
const url = `file://${htmlPath}${agentId ? '?agent=' + agentId : ''}`;
|
|
816
|
-
try {
|
|
817
|
-
(0, child_process_1.execSync)(`osascript -e 'tell application "Google Chrome" to open location "${url}"'`);
|
|
818
|
-
console.log(`✅ Chrome에서 그래프 열기: ${agentId || '전체'}`);
|
|
819
|
-
}
|
|
820
|
-
catch {
|
|
821
|
-
try {
|
|
822
|
-
(0, child_process_1.execSync)(`osascript -e 'tell application "Safari" to open location "${url}"'`);
|
|
823
|
-
console.log(`✅ Safari에서 그래프 열기: ${agentId || '전체'}`);
|
|
824
|
-
}
|
|
825
|
-
catch {
|
|
826
|
-
(0, child_process_1.execSync)(`open "${url}"`);
|
|
827
|
-
console.log(`✅ 기본 브라우저에서 그래프 열기: ${agentId || '전체'}`);
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
}
|
|
831
|
-
}
|
|
832
|
-
exports.MindmapEngine = MindmapEngine;
|
|
833
|
-
function normalizeFormatOption(format) {
|
|
834
|
-
if (!format || format === true)
|
|
835
|
-
return 'mermaid';
|
|
836
|
-
return String(format).toLowerCase();
|
|
837
|
-
}
|
|
838
|
-
//# sourceMappingURL=mindmap.js.map
|
|
328
|
+
</html>`}function F(a){if(!a)return null;const t=String(a);const o=t.includes("T")?new Date(t):new Date(`${t}T00:00:00Z`);return Number.isNaN(o.getTime())?null:o}function P(a,t){if(!t||t===true||t==="all"){return{graph:a,label:null,invalid:false}}const o=String(t).toLowerCase();const i=L[o];if(!i){return{graph:a,label:null,invalid:true}}const n=Date.now()-i.ms;const r=(a.nodes||[]).filter(l=>{const d=F(l.date);return d&&d.getTime()>=n});const s=new Set(r.map(l=>l.id));const e=(a.edges||[]).filter(l=>s.has(l.from)&&s.has(l.to));return{graph:{...a,nodes:r,edges:e,stats:{nodeCount:r.length,edgeCount:e.length}},label:i.label,invalid:false}}function R(a,t=30){const o=a?String(a):"";if(o.length<=t)return o;return o.slice(0,t)}function _(a){return String(a).replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\r?\n/g," ")}function y(a){return String(a||"").replace(/[^a-zA-Z0-9_-]/g,"_")}function C(a,t){if(!t||t.length===0)return a;const o=new Map;for(const n of t){if(n&&n.id){o.set(n.id,Boolean(n.important))}}if(o.size===0)return a;const i=(a.nodes||[]).map(n=>{if(o.has(n.id)){return{...n,important:o.get(n.id)}}return n});return{...a,nodes:i}}function T(a){const t=[];t.push("```mermaid");t.push("graph LR");const o={};for(const r of a.nodes||[]){const s=r.tags?.[0]||"general";if(!o[s])o[s]=[];o[s].push(r)}const i=Object.keys(o).sort((r,s)=>r.localeCompare(s));for(const r of i){const s=y(r||"general");t.push(` subgraph ${s}`);const e=o[r].slice().sort((l,d)=>{const u=String(l.id||"");const h=String(d.id||"");return u.localeCompare(h)});for(const l of e){const d=R(l.summary||l.id||"Unknown",30);const u=l.important?`\u2B50 ${d}`:d;const h=_(u);const c=y(l.id);t.push(` ${c}["${h}"]`)}t.push(" end")}const n=(a.edges||[]).filter(r=>Number(r.weight)>=.5);for(const r of n){const s=y(r.from);const e=y(r.to);const l=Number.isFinite(r.weight)?r.weight:Number(r.weight);const d=Number.isFinite(l)?l:r.weight;t.push(` ${s} -->|${d}| ${e}`)}t.push("```");return t.join("\n")}function N(a,t,o){console.log(`# ${t} relation graph
|
|
329
|
+
`);if(o.label&&!o.invalid){console.log(`> (Period filter: ${o.label})`)}console.log(`> Last updated: ${a.updated||"-"}`);console.log(`> Nodes: ${a.nodes.length} items | Edges: ${a.edges.length} items
|
|
330
|
+
`);if(a.nodes.length===0){console.log("No nodes match this period.");return}const i={};for(const s of a.nodes){const e=s.tags?.[0]||"general";if(!i[e])i[e]=[];i[e].push(s)}console.log(`## Clusters by tag
|
|
331
|
+
`);for(const[s,e]of Object.entries(i).sort((l,d)=>d[1].length-l[1].length)){console.log(`### ${s} (${e.length} items)`);for(const l of e.slice(0,5)){const d=a.edges.filter(u=>u.from===l.id||u.to===l.id).length;console.log(`- [${l.id}] ${l.summary} (Relations: ${d})`)}if(e.length>5){console.log(`- ... plus ${e.length-5} items`)}console.log("")}const n={};for(const s of a.edges){n[s.from]=(n[s.from]||0)+1;n[s.to]=(n[s.to]||0)+1}const r=Object.entries(n).sort((s,e)=>e[1]-s[1]).slice(0,5);if(r.length>0){console.log(`## Hub nodes (highly connected memories)
|
|
332
|
+
`);const s={};a.nodes.forEach(e=>s[e.id]=e);for(const[e,l]of r){const d=s[e];if(d){console.log(`- [${e}] ${d.summary} - ${l} relations`)}}}}class G{constructor(t){this.dataDir=t}getAgentDir(t){return p.default.join(this.dataDir,t)}getEntriesDir(t){return p.default.join(this.getAgentDir(t),"entries")}getGraphPath(t){return p.default.join(this.getAgentDir(t),"graph.json")}getHtmlPath(){return p.default.join(this.dataDir,"mindmap.html")}build(t,o={}){console.log(`\u{1F528} Building graph for ${t}...
|
|
333
|
+
`);const i=this.getEntriesDir(t);const n=k(i,{edgeThreshold:.3,...o});if(!n){console.log("No memories found.");return}b(this.getGraphPath(t),n);console.log(`\u2705 Graph build complete!`);console.log(` Nodes: ${n.stats.nodeCount} items`);console.log(` Edges: ${n.stats.edgeCount} items`);console.log(` File: ${t}/graph.json`);if(n.edges.length>0){console.log(`
|
|
334
|
+
\u{1F4CA} Top relations (top 10 by weight):`);const r=n.edges.sort((e,l)=>l.weight-e.weight).slice(0,10);const s={};n.nodes.forEach(e=>s[e.id]=e.summary);for(const e of r){const l=(s[e.from]||e.from).slice(0,25);const d=(s[e.to]||e.to).slice(0,25);console.log(` [${e.weight}] ${l}... \u2194 ${d}...`)}}}show(t,o={}){const i=f(this.getGraphPath(t));if(!i.nodes||i.nodes.length===0){console.log("No graph found. Run the build command first.");return}const n=P(i,o.period);if(n.invalid){console.log(`\u26A0\uFE0F Unknown period: ${o.period} (stm|mtm|ltm)`)}let r=n.invalid?i:n.graph;const s=w(this.getEntriesDir(t));r=C(r,s);const e=z(o.format);if(e==="text"){N(r,t,n);return}if(!r.nodes||r.nodes.length===0){console.log("No nodes match this period.");return}if(n.label&&!n.invalid){console.log(`(Period filter: ${n.label})`)}console.log(T(r))}related(t,o){const i=f(this.getGraphPath(t));if(!i.nodes||i.nodes.length===0){console.log("No graph found. Run the build command first.");return}const n=i.nodes.find(e=>e.id===o);if(!n){console.log(`ID '${o}' not found.`);return}console.log(`## \u{1F517} [${o}] ${n.summary}
|
|
335
|
+
`);console.log(`- Date: ${n.date||"-"}`);console.log(`- Tags: ${(n.tags||[]).join(", ")||"-"}
|
|
336
|
+
`);const r=i.edges.filter(e=>e.from===o||e.to===o);if(r.length===0){console.log("No related memories found.");return}console.log(`### Related memories (${r.length} items)
|
|
337
|
+
`);const s={};i.nodes.forEach(e=>s[e.id]=e);r.sort((e,l)=>l.weight-e.weight);for(const e of r){const l=e.from===o?e.to:e.from;const d=s[l];if(d){const u=e.reasons.join(", ");console.log(`[${e.weight}] [${l}] ${d.summary}`);console.log(` \u2514\u2500 Relation reason: ${u}`)}}}add(t,o,i,n="manual"){const r=f(this.getGraphPath(t));if(!r.nodes||r.nodes.length===0){console.log("No graph found. Run the build command first.");return}const s=r.nodes.find(d=>d.id===o);const e=r.nodes.find(d=>d.id===i);if(!s){console.log(`ID '${o}' not found.`);return}if(!e){console.log(`ID '${i}' not found.`);return}const l=r.edges.find(d=>d.from===o&&d.to===i||d.from===i&&d.to===o);if(l){console.log(`Already related: weight ${l.weight}`);return}r.edges.push({from:o,to:i,type:n,weight:1,reasons:[n],manual:true});b(this.getGraphPath(t),r);console.log(`\u2705 Relation added!`);console.log(` ${(s.summary||"").slice(0,30)}...`);console.log(` \u2194`);console.log(` ${(e.summary||"").slice(0,30)}...`)}remove(t,o,i){const n=f(this.getGraphPath(t));if(!n.edges||n.edges.length===0){console.log("No relations found.");return}const r=n.edges.findIndex(s=>s.from===o&&s.to===i||s.from===i&&s.to===o);if(r===-1){console.log("Relation not found.");return}n.edges.splice(r,1);b(this.getGraphPath(t),n);console.log(`\u{1F5D1}\uFE0F Relation removed: ${o} \u2194 ${i}`)}html(){if(!g.default.existsSync(this.dataDir)){console.log("Data directory not found.");return}const t=g.default.readdirSync(this.dataDir).filter(e=>{const l=p.default.join(this.dataDir,e);try{return g.default.statSync(l).isDirectory()}catch{return false}});const o={};let i=0;let n=0;for(const e of t){const l=f(this.getGraphPath(e));if(l.nodes&&l.nodes.length>0){o[e]=l;i+=l.nodes.length;n+=l.edges.length}}if(Object.keys(o).length===0){console.log("No graph found. Run the build command first.");return}const r=E(o,{title:"Memory Graph - All Agents"});if(!r){console.log("HTML generation failed");return}const s=this.getHtmlPath();g.default.writeFileSync(s,r,"utf-8");console.log(`\u2705 Shared graph visualization generated!`);console.log(` File: ${s}`);console.log(` Agents: ${Object.keys(o).length} items`);console.log(` all Nodes: ${i} items | all Edges: ${n} items`);console.log(`
|
|
338
|
+
Open in browser: open ${s}`)}open(t){const o=this.getHtmlPath();if(!g.default.existsSync(o)){console.log("mindmap.html not found. Run the html command first.");return}const i=`file://${o}${t?"?agent="+t:""}`;try{(0,x.execSync)(`osascript -e 'tell application "Google Chrome" to open location "${i}"'`);console.log(`\u2705 Opening graph in Chrome: ${t||"all"}`)}catch{try{(0,x.execSync)(`osascript -e 'tell application "Safari" to open location "${i}"'`);console.log(`\u2705 Opening graph in Safari: ${t||"all"}`)}catch{(0,x.execSync)(`open "${i}"`);console.log(`\u2705 Opening graph in the default browser: ${t||"all"}`)}}}}exports.MindmapEngine=G;function z(a){if(!a||a===true)return"mermaid";return String(a).toLowerCase()}
|
package/dist/src/parser.d.ts
CHANGED
package/dist/src/parser.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.stringifyFrontmatter = exports.parseFrontmatter = void 0;
|
|
4
|
-
var knowledge_core_1 = require("@crewx/knowledge-core");
|
|
5
|
-
Object.defineProperty(exports, "parseFrontmatter", { enumerable: true, get: function () { return knowledge_core_1.parseFrontmatter; } });
|
|
6
|
-
Object.defineProperty(exports, "stringifyFrontmatter", { enumerable: true, get: function () { return knowledge_core_1.stringifyFrontmatter; } });
|
|
7
|
-
//# sourceMappingURL=parser.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.stringifyFrontmatter=exports.parseFrontmatter=void 0;var e=require("@crewx/knowledge-core");Object.defineProperty(exports,"parseFrontmatter",{enumerable:true,get:function(){return e.parseFrontmatter}});Object.defineProperty(exports,"stringifyFrontmatter",{enumerable:true,get:function(){return e.stringifyFrontmatter}});
|
package/dist/src/types.d.ts
CHANGED
package/dist/src/types.js
CHANGED
|
@@ -1,15 +1 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CATEGORIES = void 0;
|
|
4
|
-
exports.CATEGORIES = [
|
|
5
|
-
'decision',
|
|
6
|
-
'schedule',
|
|
7
|
-
'task',
|
|
8
|
-
'project',
|
|
9
|
-
'context',
|
|
10
|
-
'preference',
|
|
11
|
-
'general',
|
|
12
|
-
'backlog',
|
|
13
|
-
'knowhow',
|
|
14
|
-
];
|
|
15
|
-
//# sourceMappingURL=types.js.map
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.CATEGORIES=void 0;exports.CATEGORIES=["decision","schedule","task","project","context","preference","general","backlog","knowhow"];
|