monomind 1.16.11 → 1.17.1

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.
Files changed (148) hide show
  1. package/.claude/agents/engineering/engineering-security-engineer.md +1 -1
  2. package/.claude/agents/github/code-review-swarm.md +19 -19
  3. package/.claude/agents/github/github-modes.md +4 -4
  4. package/.claude/agents/github/multi-repo-swarm.md +24 -24
  5. package/.claude/agents/github/project-board-sync.md +28 -28
  6. package/.claude/agents/github/swarm-issue.md +26 -26
  7. package/.claude/agents/github/swarm-pr.md +18 -18
  8. package/.claude/agents/github/workflow-automation.md +27 -27
  9. package/.claude/agents/reengineer-squad/git-manager.md +2 -2
  10. package/.claude/commands/mastermind/_repeat.md +4 -0
  11. package/.claude/commands/mastermind/master.md +61 -4
  12. package/.claude/commands/mastermind/references/antigravity-tools.md +60 -0
  13. package/.claude/commands/mastermind/references/claude-code-tools.md +50 -0
  14. package/.claude/commands/mastermind/references/codex-tools.md +64 -0
  15. package/.claude/commands/mastermind/references/copilot-tools.md +49 -0
  16. package/.claude/commands/mastermind/references/gemini-tools.md +63 -0
  17. package/.claude/commands/mastermind/references/pi-tools.md +28 -0
  18. package/.claude/helpers/mastermind-activate.cjs +53 -0
  19. package/.claude/scheduled_tasks.lock +1 -1
  20. package/.claude/settings.json +4 -0
  21. package/.claude/skills/mastermind/_repeat.md +2 -0
  22. package/.claude/skills/mastermind/runorg.md +14 -0
  23. package/.claude/skills/mastermind/techport.md +5 -5
  24. package/README.md +1 -1
  25. package/package.json +6 -5
  26. package/packages/@monomind/cli/.claude/agents/engineering/engineering-security-engineer.md +1 -1
  27. package/packages/@monomind/cli/.claude/agents/github/code-review-swarm.md +19 -19
  28. package/packages/@monomind/cli/.claude/agents/github/github-modes.md +4 -4
  29. package/packages/@monomind/cli/.claude/agents/github/multi-repo-swarm.md +24 -24
  30. package/packages/@monomind/cli/.claude/agents/github/project-board-sync.md +28 -28
  31. package/packages/@monomind/cli/.claude/agents/github/swarm-issue.md +26 -26
  32. package/packages/@monomind/cli/.claude/agents/github/swarm-pr.md +18 -18
  33. package/packages/@monomind/cli/.claude/agents/github/workflow-automation.md +27 -27
  34. package/packages/@monomind/cli/.claude/agents/reengineer-squad/git-manager.md +2 -2
  35. package/packages/@monomind/cli/.claude/commands/mastermind/_repeat.md +4 -0
  36. package/packages/@monomind/cli/.claude/commands/mastermind/master.md +61 -4
  37. package/packages/@monomind/cli/.claude/commands/mastermind/references/antigravity-tools.md +60 -0
  38. package/packages/@monomind/cli/.claude/commands/mastermind/references/claude-code-tools.md +50 -0
  39. package/packages/@monomind/cli/.claude/commands/mastermind/references/codex-tools.md +64 -0
  40. package/packages/@monomind/cli/.claude/commands/mastermind/references/copilot-tools.md +49 -0
  41. package/packages/@monomind/cli/.claude/commands/mastermind/references/gemini-tools.md +63 -0
  42. package/packages/@monomind/cli/.claude/commands/mastermind/references/pi-tools.md +28 -0
  43. package/packages/@monomind/cli/.claude/helpers/mastermind-activate.cjs +53 -0
  44. package/packages/@monomind/cli/.claude/skills/mastermind/_repeat.md +2 -0
  45. package/packages/@monomind/cli/.claude/skills/mastermind/runorg.md +14 -0
  46. package/packages/@monomind/cli/.claude/skills/mastermind/techport.md +5 -5
  47. package/packages/@monomind/cli/README.md +1 -1
  48. package/packages/@monomind/cli/dist/src/__tests__/browse-analyzer.test.js +42 -59
  49. package/packages/@monomind/cli/dist/src/browser/dashboard/server.js +18 -0
  50. package/packages/@monomind/cli/dist/src/commands/agent-lifecycle.d.ts +17 -0
  51. package/packages/@monomind/cli/dist/src/commands/agent-lifecycle.js +320 -0
  52. package/packages/@monomind/cli/dist/src/commands/agent-ops.d.ts +9 -0
  53. package/packages/@monomind/cli/dist/src/commands/agent-ops.js +329 -0
  54. package/packages/@monomind/cli/dist/src/commands/agent.js +5 -907
  55. package/packages/@monomind/cli/dist/src/commands/analyze-ast.d.ts +26 -0
  56. package/packages/@monomind/cli/dist/src/commands/analyze-ast.js +284 -0
  57. package/packages/@monomind/cli/dist/src/commands/analyze-boundaries.d.ts +14 -0
  58. package/packages/@monomind/cli/dist/src/commands/analyze-boundaries.js +295 -0
  59. package/packages/@monomind/cli/dist/src/commands/analyze-diff.d.ts +8 -0
  60. package/packages/@monomind/cli/dist/src/commands/analyze-diff.js +395 -0
  61. package/packages/@monomind/cli/dist/src/commands/analyze-graph.d.ts +14 -0
  62. package/packages/@monomind/cli/dist/src/commands/analyze-graph.js +304 -0
  63. package/packages/@monomind/cli/dist/src/commands/analyze-imports.d.ts +11 -0
  64. package/packages/@monomind/cli/dist/src/commands/analyze-imports.js +287 -0
  65. package/packages/@monomind/cli/dist/src/commands/analyze-symbols.d.ts +14 -0
  66. package/packages/@monomind/cli/dist/src/commands/analyze-symbols.js +302 -0
  67. package/packages/@monomind/cli/dist/src/commands/analyze.d.ts +38 -0
  68. package/packages/@monomind/cli/dist/src/commands/analyze.js +12 -1827
  69. package/packages/@monomind/cli/dist/src/commands/doctor-env-checks.d.ts +26 -0
  70. package/packages/@monomind/cli/dist/src/commands/doctor-env-checks.js +189 -0
  71. package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.d.ts +19 -0
  72. package/packages/@monomind/cli/dist/src/commands/doctor-project-checks.js +388 -0
  73. package/packages/@monomind/cli/dist/src/commands/doctor.js +51 -942
  74. package/packages/@monomind/cli/dist/src/commands/hive-mind-comms.d.ts +11 -0
  75. package/packages/@monomind/cli/dist/src/commands/hive-mind-comms.js +242 -0
  76. package/packages/@monomind/cli/dist/src/commands/hive-mind-helpers.d.ts +35 -0
  77. package/packages/@monomind/cli/dist/src/commands/hive-mind-helpers.js +203 -0
  78. package/packages/@monomind/cli/dist/src/commands/hive-mind-ops.d.ts +8 -0
  79. package/packages/@monomind/cli/dist/src/commands/hive-mind-ops.js +233 -0
  80. package/packages/@monomind/cli/dist/src/commands/hive-mind-spawn.d.ts +12 -0
  81. package/packages/@monomind/cli/dist/src/commands/hive-mind-spawn.js +274 -0
  82. package/packages/@monomind/cli/dist/src/commands/hive-mind.js +10 -1129
  83. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-commands.d.ts +4 -4
  84. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-commands.js +19 -819
  85. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-gaps.d.ts +7 -0
  86. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-gaps.js +334 -0
  87. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-routing.d.ts +7 -0
  88. package/packages/@monomind/cli/dist/src/commands/hooks-coverage-routing.js +399 -0
  89. package/packages/@monomind/cli/dist/src/commands/index.js +0 -2
  90. package/packages/@monomind/cli/dist/src/commands/init-subcommands.d.ts +8 -0
  91. package/packages/@monomind/cli/dist/src/commands/init-subcommands.js +156 -0
  92. package/packages/@monomind/cli/dist/src/commands/init-upgrade.d.ts +6 -0
  93. package/packages/@monomind/cli/dist/src/commands/init-upgrade.js +203 -0
  94. package/packages/@monomind/cli/dist/src/commands/init-wizard.d.ts +6 -0
  95. package/packages/@monomind/cli/dist/src/commands/init-wizard.js +246 -0
  96. package/packages/@monomind/cli/dist/src/commands/init.js +6 -623
  97. package/packages/@monomind/cli/dist/src/commands/memory-admin.d.ts +10 -0
  98. package/packages/@monomind/cli/dist/src/commands/memory-admin.js +433 -0
  99. package/packages/@monomind/cli/dist/src/commands/memory-crud.d.ts +9 -0
  100. package/packages/@monomind/cli/dist/src/commands/memory-crud.js +342 -0
  101. package/packages/@monomind/cli/dist/src/commands/memory-list.d.ts +10 -0
  102. package/packages/@monomind/cli/dist/src/commands/memory-list.js +321 -0
  103. package/packages/@monomind/cli/dist/src/commands/memory-transfer.d.ts +9 -0
  104. package/packages/@monomind/cli/dist/src/commands/memory-transfer.js +372 -0
  105. package/packages/@monomind/cli/dist/src/commands/memory.d.ts +6 -0
  106. package/packages/@monomind/cli/dist/src/commands/memory.js +10 -1441
  107. package/packages/@monomind/cli/dist/src/commands/neural-core.d.ts +8 -0
  108. package/packages/@monomind/cli/dist/src/commands/neural-core.js +274 -0
  109. package/packages/@monomind/cli/dist/src/commands/neural-optimize.d.ts +7 -0
  110. package/packages/@monomind/cli/dist/src/commands/neural-optimize.js +332 -0
  111. package/packages/@monomind/cli/dist/src/commands/neural-registry.d.ts +7 -0
  112. package/packages/@monomind/cli/dist/src/commands/neural-registry.js +290 -0
  113. package/packages/@monomind/cli/dist/src/commands/neural.js +3 -974
  114. package/packages/@monomind/cli/dist/src/commands/platforms.js +327 -7
  115. package/packages/@monomind/cli/dist/src/commands/security-cve.d.ts +6 -0
  116. package/packages/@monomind/cli/dist/src/commands/security-cve.js +310 -0
  117. package/packages/@monomind/cli/dist/src/commands/security-misc.d.ts +9 -0
  118. package/packages/@monomind/cli/dist/src/commands/security-misc.js +293 -0
  119. package/packages/@monomind/cli/dist/src/commands/security-scan.d.ts +18 -0
  120. package/packages/@monomind/cli/dist/src/commands/security-scan.js +328 -0
  121. package/packages/@monomind/cli/dist/src/commands/security.js +3 -958
  122. package/packages/@monomind/cli/dist/src/commands/session.js +1 -1
  123. package/packages/@monomind/cli/dist/src/commands/swarm.js +23 -17
  124. package/packages/@monomind/cli/dist/src/init/executor.js +0 -24
  125. package/packages/@monomind/cli/dist/src/init/statusline-generator.js +0 -45
  126. package/packages/@monomind/cli/dist/src/init/types.d.ts +0 -2
  127. package/packages/@monomind/cli/dist/src/init/types.js +0 -2
  128. package/packages/@monomind/cli/dist/src/mcp-tools/swarm-tools.js +77 -0
  129. package/packages/@monomind/cli/dist/src/parser.js +11 -6
  130. package/packages/@monomind/cli/dist/src/routing/llm-caller.js +1 -2
  131. package/packages/@monomind/cli/dist/src/ui/dashboard.html +82 -75
  132. package/packages/@monomind/cli/dist/src/ui/server.mjs +41 -4
  133. package/packages/@monomind/cli/package.json +3 -4
  134. package/packages/@monomind/cli/scripts/understand-analyze.mjs +1 -1
  135. package/packages/@monomind/guidance/README.md +0 -1
  136. package/packages/@monomind/guidance/package.json +2 -14
  137. package/scripts/verify-appliance.sh +16 -20
  138. package/.claude-plugin/README.md +0 -704
  139. package/.claude-plugin/docs/INSTALLATION.md +0 -258
  140. package/.claude-plugin/docs/PLUGIN_SUMMARY.md +0 -358
  141. package/.claude-plugin/docs/QUICKSTART.md +0 -357
  142. package/.claude-plugin/docs/STRUCTURE.md +0 -122
  143. package/.claude-plugin/hooks/hooks.json +0 -74
  144. package/.claude-plugin/marketplace.json +0 -98
  145. package/.claude-plugin/plugin.json +0 -70
  146. package/.claude-plugin/scripts/install.sh +0 -234
  147. package/.claude-plugin/scripts/uninstall.sh +0 -36
  148. package/.claude-plugin/scripts/verify.sh +0 -102
@@ -0,0 +1,372 @@
1
+ /**
2
+ * Memory Transfer Commands
3
+ * compressCommand, exportCommand, importCommand
4
+ */
5
+ import { output } from '../output.js';
6
+ import { callMCPTool, MCPClientError } from '../mcp-client.js';
7
+ // Compress command
8
+ export const compressCommand = {
9
+ name: 'compress',
10
+ description: 'Compress and optimize memory storage',
11
+ options: [
12
+ {
13
+ name: 'level',
14
+ short: 'l',
15
+ description: 'Compression level (fast, balanced, max)',
16
+ type: 'string',
17
+ choices: ['fast', 'balanced', 'max'],
18
+ default: 'balanced'
19
+ },
20
+ {
21
+ name: 'target',
22
+ short: 't',
23
+ description: 'Target (vectors, text, patterns, all)',
24
+ type: 'string',
25
+ choices: ['vectors', 'text', 'patterns', 'all'],
26
+ default: 'all'
27
+ },
28
+ {
29
+ name: 'quantize',
30
+ short: 'z',
31
+ description: 'Enable vector quantization (reduces memory 4-32x)',
32
+ type: 'boolean',
33
+ default: false
34
+ },
35
+ {
36
+ name: 'bits',
37
+ description: 'Quantization bits (4, 8, 16)',
38
+ type: 'number',
39
+ default: 8
40
+ },
41
+ {
42
+ name: 'rebuild-index',
43
+ short: 'r',
44
+ description: 'Rebuild HNSW index after compression',
45
+ type: 'boolean',
46
+ default: true
47
+ }
48
+ ],
49
+ examples: [
50
+ { command: 'monomind memory compress', description: 'Balanced compression' },
51
+ { command: 'monomind memory compress --quantize --bits 4', description: '4-bit quantization (32x reduction)' },
52
+ { command: 'monomind memory compress -l max -t vectors', description: 'Max compression on vectors' }
53
+ ],
54
+ action: async (ctx) => {
55
+ const level = ctx.flags.level || 'balanced';
56
+ const target = ctx.flags.target || 'all';
57
+ const quantize = ctx.flags.quantize;
58
+ const bits = ctx.flags.bits || 8;
59
+ const rebuildIndex = ctx.flags.rebuildIndex ?? true;
60
+ output.writeln();
61
+ output.writeln(output.bold('Memory Compression'));
62
+ output.writeln(output.dim(`Level: ${level}, Target: ${target}, Quantize: ${quantize ? `${bits}-bit` : 'no'}`));
63
+ output.writeln();
64
+ const spinner = output.createSpinner({ text: 'Analyzing current storage...', spinner: 'dots' });
65
+ spinner.start();
66
+ try {
67
+ const result = await callMCPTool('memory_compress', {
68
+ level,
69
+ target,
70
+ quantize,
71
+ bits,
72
+ rebuildIndex,
73
+ });
74
+ spinner.succeed('Compression complete');
75
+ if (ctx.flags.format === 'json') {
76
+ output.printJson(result);
77
+ return { success: true, data: result };
78
+ }
79
+ output.writeln();
80
+ output.writeln(output.bold('Storage Comparison'));
81
+ output.printTable({
82
+ columns: [
83
+ { key: 'category', header: 'Category', width: 15 },
84
+ { key: 'before', header: 'Before', width: 12, align: 'right' },
85
+ { key: 'after', header: 'After', width: 12, align: 'right' },
86
+ { key: 'saved', header: 'Saved', width: 12, align: 'right' }
87
+ ],
88
+ data: [
89
+ { category: 'Vectors', before: result.before.vectorsSize, after: result.after.vectorsSize, saved: '-' },
90
+ { category: 'Text', before: result.before.textSize, after: result.after.textSize, saved: '-' },
91
+ { category: 'Patterns', before: result.before.patternsSize, after: result.after.patternsSize, saved: '-' },
92
+ { category: 'Index', before: result.before.indexSize, after: result.after.indexSize, saved: '-' },
93
+ { category: output.bold('Total'), before: result.before.totalSize, after: result.after.totalSize, saved: output.success(result.compression.formattedSaved) }
94
+ ]
95
+ });
96
+ output.writeln();
97
+ output.printBox([
98
+ `Compression Ratio: ${result.compression.ratio.toFixed(2)}x`,
99
+ `Space Saved: ${result.compression.formattedSaved}`,
100
+ `Quantization: ${result.compression.quantizationApplied ? `Yes (${bits}-bit)` : 'No'}`,
101
+ `Index Rebuilt: ${result.compression.indexRebuilt ? 'Yes' : 'No'}`,
102
+ `Duration: ${(result.duration / 1000).toFixed(1)}s`
103
+ ].join('\n'), 'Results');
104
+ if (result.performance) {
105
+ output.writeln();
106
+ output.writeln(output.bold('Performance Impact'));
107
+ output.printList([
108
+ `Search latency: ${result.performance.searchLatencyBefore.toFixed(2)}ms → ${result.performance.searchLatencyAfter.toFixed(2)}ms`,
109
+ `Speedup: ${output.success(result.performance.searchSpeedup)}`
110
+ ]);
111
+ }
112
+ return { success: true, data: result };
113
+ }
114
+ catch (error) {
115
+ spinner.fail('Compression failed');
116
+ if (error instanceof MCPClientError) {
117
+ output.printError(`Compression error: ${error.message}`);
118
+ }
119
+ else {
120
+ output.printError(`Unexpected error: ${String(error)}`);
121
+ }
122
+ return { success: false, exitCode: 1 };
123
+ }
124
+ }
125
+ };
126
+ // Export command
127
+ export const exportCommand = {
128
+ name: 'export',
129
+ description: 'Export memory to file',
130
+ options: [
131
+ {
132
+ name: 'output',
133
+ short: 'o',
134
+ description: 'Output file path',
135
+ type: 'string',
136
+ required: true
137
+ },
138
+ {
139
+ name: 'format',
140
+ short: 'f',
141
+ description: 'Export format (json, csv, binary, okf)',
142
+ type: 'string',
143
+ choices: ['json', 'csv', 'binary', 'okf'],
144
+ default: 'json'
145
+ },
146
+ {
147
+ name: 'namespace',
148
+ short: 'n',
149
+ description: 'Export specific namespace',
150
+ type: 'string'
151
+ },
152
+ {
153
+ name: 'include-vectors',
154
+ description: 'Include vector embeddings',
155
+ type: 'boolean',
156
+ default: true
157
+ }
158
+ ],
159
+ examples: [
160
+ { command: 'monomind memory export -o ./backup.json', description: 'Export all to JSON' },
161
+ { command: 'monomind memory export -o ./data.csv -f csv', description: 'Export to CSV' },
162
+ { command: 'monomind memory export -o ./knowledge -f okf', description: 'Export as OKF bundle (directory of .md files)' }
163
+ ],
164
+ action: async (ctx) => {
165
+ const outputPath = ctx.flags.output;
166
+ const format = ctx.flags.format || 'json';
167
+ if (!outputPath) {
168
+ output.printError('Output path is required. Use --output or -o');
169
+ return { success: false, exitCode: 1 };
170
+ }
171
+ output.printInfo(`Exporting memory to ${outputPath}...`);
172
+ // OKF bundle: native export — directory of .md files with YAML frontmatter
173
+ if (format === 'okf') {
174
+ try {
175
+ const fs = await import('fs');
176
+ const path = await import('path');
177
+ const { listEntries, getEntry } = await import('../memory/memory-initializer.js');
178
+ const namespace = ctx.flags.namespace;
179
+ const listed = await listEntries({ namespace, limit: 10000 });
180
+ if (!listed.success) {
181
+ output.printError(`Failed to list entries: ${listed.error}`);
182
+ return { success: false, exitCode: 1 };
183
+ }
184
+ let written = 0;
185
+ for (const entry of listed.entries) {
186
+ const got = await getEntry({ key: entry.key, namespace: entry.namespace });
187
+ if (!got.found || !got.entry)
188
+ continue;
189
+ const { key, namespace: ns, content, tags, createdAt } = got.entry;
190
+ const safeKey = key.replace(/[/\\:*?"<>|]/g, '-');
191
+ const dir = path.join(outputPath, ns);
192
+ fs.mkdirSync(dir, { recursive: true });
193
+ const yamlEscape = (s) => s.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
194
+ const tagsLine = tags.length > 0 ? `tags: [${tags.join(', ')}]\n` : '';
195
+ const md = `---\ntype: Memory\nkey: "${yamlEscape(key)}"\nnamespace: "${yamlEscape(ns)}"\n${tagsLine}timestamp: ${createdAt}\n---\n\n${content}`;
196
+ fs.writeFileSync(path.join(dir, `${safeKey}.md`), md, 'utf-8');
197
+ written++;
198
+ }
199
+ output.printSuccess(`Exported ${written} entries to ${outputPath}`);
200
+ if (listed.total > 10000) {
201
+ output.printInfo(`Note: only first 10000 of ${listed.total} entries exported`);
202
+ }
203
+ return { success: true, data: { written, outputPath } };
204
+ }
205
+ catch (error) {
206
+ output.printError(`OKF export error: ${String(error)}`);
207
+ return { success: false, exitCode: 1 };
208
+ }
209
+ }
210
+ try {
211
+ const result = await callMCPTool('memory_export', {
212
+ outputPath,
213
+ format,
214
+ namespace: ctx.flags.namespace,
215
+ includeVectors: ctx.flags.includeVectors ?? true,
216
+ });
217
+ output.printSuccess(`Exported to ${result.outputPath}`);
218
+ output.printList([
219
+ `Entries: ${result.exported.entries}`,
220
+ `Vectors: ${result.exported.vectors}`,
221
+ `Patterns: ${result.exported.patterns}`,
222
+ `File size: ${result.fileSize}`
223
+ ]);
224
+ return { success: true, data: result };
225
+ }
226
+ catch (error) {
227
+ if (error instanceof MCPClientError) {
228
+ output.printError(`Export error: ${error.message}`);
229
+ }
230
+ else {
231
+ output.printError(`Unexpected error: ${String(error)}`);
232
+ }
233
+ return { success: false, exitCode: 1 };
234
+ }
235
+ }
236
+ };
237
+ // Import command
238
+ export const importCommand = {
239
+ name: 'import',
240
+ description: 'Import memory from file',
241
+ options: [
242
+ {
243
+ name: 'input',
244
+ short: 'i',
245
+ description: 'Input file path',
246
+ type: 'string',
247
+ required: true
248
+ },
249
+ {
250
+ name: 'merge',
251
+ short: 'm',
252
+ description: 'Merge with existing (skip duplicates)',
253
+ type: 'boolean',
254
+ default: true
255
+ },
256
+ {
257
+ name: 'namespace',
258
+ short: 'n',
259
+ description: 'Import into specific namespace',
260
+ type: 'string'
261
+ }
262
+ ],
263
+ examples: [
264
+ { command: 'monomind memory import -i ./backup.json', description: 'Import from file' },
265
+ { command: 'monomind memory import -i ./data.json -n archive', description: 'Import to namespace' }
266
+ ],
267
+ action: async (ctx) => {
268
+ const inputPath = ctx.flags.input || ctx.args[0];
269
+ if (!inputPath) {
270
+ output.printError('Input path is required. Use --input or -i');
271
+ return { success: false, exitCode: 1 };
272
+ }
273
+ output.printInfo(`Importing memory from ${inputPath}...`);
274
+ // OKF bundle: native import — detect directory of .md files with YAML frontmatter
275
+ const fsCheck = await import('fs');
276
+ const isDir = fsCheck.existsSync(inputPath) && fsCheck.statSync(inputPath).isDirectory();
277
+ if (isDir) {
278
+ try {
279
+ const fs = await import('fs');
280
+ const path = await import('path');
281
+ const { storeEntry } = await import('../memory/memory-initializer.js');
282
+ function parseOkfFrontmatter(raw) {
283
+ if (!raw.startsWith('---\n'))
284
+ return { meta: {}, body: raw };
285
+ const end = raw.indexOf('\n---\n', 4);
286
+ if (end === -1)
287
+ return { meta: {}, body: raw };
288
+ const meta = {};
289
+ for (const line of raw.slice(4, end).split('\n')) {
290
+ const colon = line.indexOf(':');
291
+ if (colon <= 0)
292
+ continue;
293
+ const k = line.slice(0, colon).trim();
294
+ const rawV = line.slice(colon + 1).trim();
295
+ const isQuoted = rawV.startsWith('"') && rawV.endsWith('"') && rawV.length >= 2;
296
+ const v = isQuoted ? rawV.slice(1, -1).replace(/\\(["\\])/g, '$1') : rawV;
297
+ if (v.startsWith('[') && v.endsWith(']')) {
298
+ meta[k] = v.slice(1, -1).split(',').map(s => s.trim()).filter(Boolean);
299
+ }
300
+ else {
301
+ meta[k] = v;
302
+ }
303
+ }
304
+ return { meta, body: raw.slice(end + 5) };
305
+ }
306
+ function findMdFiles(dir) {
307
+ const results = [];
308
+ for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
309
+ const full = path.join(dir, entry.name);
310
+ if (entry.isDirectory())
311
+ results.push(...findMdFiles(full));
312
+ else if (entry.name.endsWith('.md'))
313
+ results.push(full);
314
+ }
315
+ return results;
316
+ }
317
+ const overrideNs = ctx.flags.namespace;
318
+ const merge = ctx.flags.merge ?? true;
319
+ const files = findMdFiles(inputPath);
320
+ let imported = 0, skipped = 0;
321
+ const start = Date.now();
322
+ for (const file of files) {
323
+ const raw = fs.readFileSync(file, 'utf-8');
324
+ const { meta, body } = parseOkfFrontmatter(raw);
325
+ const key = meta['key'] || path.basename(file, '.md');
326
+ const ns = overrideNs || meta['namespace'] || path.basename(path.dirname(file));
327
+ const tags = Array.isArray(meta['tags']) ? meta['tags'] : meta['tags'] ? [meta['tags']] : [];
328
+ const result = await storeEntry({ key, value: body.trim(), namespace: ns, tags, upsert: !merge });
329
+ if (result.success)
330
+ imported++;
331
+ else
332
+ skipped++;
333
+ }
334
+ output.printSuccess(`Imported ${imported} entries from ${inputPath}`);
335
+ if (skipped > 0)
336
+ output.printInfo(`Skipped ${skipped} entries (duplicates or errors)`);
337
+ output.printInfo(`Duration: ${Date.now() - start}ms`);
338
+ return { success: true, data: { imported, skipped } };
339
+ }
340
+ catch (error) {
341
+ output.printError(`OKF import error: ${String(error)}`);
342
+ return { success: false, exitCode: 1 };
343
+ }
344
+ }
345
+ try {
346
+ const result = await callMCPTool('memory_import', {
347
+ inputPath,
348
+ merge: ctx.flags.merge ?? true,
349
+ namespace: ctx.flags.namespace,
350
+ });
351
+ output.printSuccess(`Imported from ${result.inputPath}`);
352
+ output.printList([
353
+ `Entries: ${result.imported.entries}`,
354
+ `Vectors: ${result.imported.vectors}`,
355
+ `Patterns: ${result.imported.patterns}`,
356
+ `Skipped (duplicates): ${result.skipped}`,
357
+ `Duration: ${result.duration}ms`
358
+ ]);
359
+ return { success: true, data: result };
360
+ }
361
+ catch (error) {
362
+ if (error instanceof MCPClientError) {
363
+ output.printError(`Import error: ${error.message}`);
364
+ }
365
+ else {
366
+ output.printError(`Unexpected error: ${String(error)}`);
367
+ }
368
+ return { success: false, exitCode: 1 };
369
+ }
370
+ }
371
+ };
372
+ //# sourceMappingURL=memory-transfer.js.map
@@ -1,6 +1,12 @@
1
1
  /**
2
2
  * CLI Memory Command
3
3
  * Memory operations for LanceDB integration
4
+ *
5
+ * Split into sub-modules:
6
+ * memory-crud.ts — store, retrieve, search
7
+ * memory-list.ts — list, edit, templates
8
+ * memory-admin.ts — delete, stats, configure, cleanup
9
+ * memory-transfer.ts — compress, export, import
4
10
  */
5
11
  import type { Command } from '../types.js';
6
12
  export declare const memoryCommand: Command;