save_data
Store lines, loops, vibes, and contexts to persistent storage for later retrieval in the LLV Helix Framework's creativity workflows.
Instructions
Save current lines, loops, vibes, and contexts to persistent storage
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| filename | No | Optional custom filename (without extension) |
Implementation Reference
- index.js:293-305 (schema)Schema definition for the save_data tool, including input schema for optional filename.{ name: 'save_data', description: 'Save current lines, loops, vibes, and contexts to persistent storage', inputSchema: { type: 'object', properties: { filename: { type: 'string', description: 'Optional custom filename (without extension)', }, }, }, },
- index.js:351-352 (registration)Registration and dispatch in the CallToolRequestSchema handler switch statement.case 'save_data': return this.saveData(args);
- index.js:1074-1121 (handler)The core handler function that executes the save_data tool: checks persistence, ensures dir, serializes Maps to JSON, writes to file, returns success/error message.async saveData(args) { if (!this.persistenceEnabled) { return { content: [ { type: 'text', text: `❌ Data persistence is disabled. Set LLV_PERSISTENCE=true to enable.`, }, ], }; } try { await this.ensureDataDir(); const filename = args.filename || 'llv-session'; const filepath = join(this.dataDir, `${filename}.json`); const data = { timestamp: new Date().toISOString(), lines: this.mapToObj(this.lines), loops: this.mapToObj(this.loops), vibes: this.mapToObj(this.vibes), contexts: this.mapToObj(this.contexts), version: '1.0.0', }; await fs.writeFile(filepath, JSON.stringify(data, null, 2)); return { content: [ { type: 'text', text: `💾 Data saved successfully!\n\nFile: ${filepath}\nLines: ${this.lines.size}\nLoops: ${this.loops.size}\nVibes: ${this.vibes.size}\nContexts: ${this.contexts.size}\n\nTimestamp: ${data.timestamp}`, }, ], }; } catch (error) { return { content: [ { type: 'text', text: `❌ Failed to save data: ${error.message}`, }, ], }; } }
- index.js:1066-1068 (helper)Helper function used by saveData to convert internal Map data structures to plain objects for JSON serialization.mapToObj(map) { return Object.fromEntries(map); }
- index.js:1058-1064 (helper)Helper function called by saveData to ensure the data persistence directory exists.async ensureDataDir() { try { await fs.mkdir(this.dataDir, { recursive: true }); } catch (error) { console.error('Failed to create data directory:', error); } }