@yamo/memory-mesh 3.1.0 → 3.1.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 (2) hide show
  1. package/bin/memory_mesh.js +58 -1
  2. package/package.json +1 -1
@@ -53,7 +53,64 @@ program
53
53
  }
54
54
  });
55
55
 
56
- // 2. Search Command
56
+ // 2. Directory Ingest Command
57
+ program
58
+ .command('ingest-dir')
59
+ .description('Recursively ingest a directory of files')
60
+ .argument('<path>', 'Directory path to ingest')
61
+ .option('-e, --extension <ext>', 'Filter by file extension (e.g., .yamo, .md)', '')
62
+ .option('-t, --type <type>', 'Memory type for all files', 'documentation')
63
+ .option('-r, --recursive', 'Ingest subdirectories', false)
64
+ .action(async (dirPath, options) => {
65
+ const mesh = new MemoryMesh();
66
+ try {
67
+ const absolutePath = path.resolve(dirPath);
68
+ if (!fs.existsSync(absolutePath)) {
69
+ throw new Error(`Directory not found: ${absolutePath}`);
70
+ }
71
+
72
+ const files = [];
73
+ const walk = (dir) => {
74
+ const entries = fs.readdirSync(dir, { withFileTypes: true });
75
+ for (const entry of entries) {
76
+ const fullPath = path.join(dir, entry.name);
77
+ if (entry.isDirectory() && options.recursive) {
78
+ walk(fullPath);
79
+ } else if (entry.isFile()) {
80
+ if (!options.extension || entry.name.endsWith(options.extension)) {
81
+ files.push(fullPath);
82
+ }
83
+ }
84
+ }
85
+ };
86
+
87
+ walk(absolutePath);
88
+ process.stdout.write(`[MemoryMesh] Found ${files.length} files to ingest...\n`);
89
+
90
+ for (const file of files) {
91
+ const content = fs.readFileSync(file, 'utf-8');
92
+ if (!content.trim()) continue;
93
+
94
+ const metadata = {
95
+ source: path.relative(process.cwd(), file),
96
+ ingested_at: new Date().toISOString(),
97
+ type: options.type
98
+ };
99
+
100
+ const record = await mesh.add(content, metadata);
101
+ process.stdout.write(` ✓ Ingested: ${metadata.source} (${record.id})\n`);
102
+ }
103
+
104
+ process.stdout.write(`[MemoryMesh] Completed bulk ingestion of ${files.length} files.\n`);
105
+ } catch (err) {
106
+ console.error(`❌ Error: ${err.message}`);
107
+ process.exit(1);
108
+ } finally {
109
+ await mesh.close();
110
+ }
111
+ });
112
+
113
+ // 3. Search Command
57
114
  program
58
115
  .command('search')
59
116
  .description('Perform semantic recall')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yamo/memory-mesh",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "Portable semantic memory system with Layer 0 Scrubber for YAMO agents (v3 Singularity Edition)",
5
5
  "type": "module",
6
6
  "main": "lib/memory/index.js",