Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

feat(meatspace): add goals export and improve MortalLoom export

Adam Eivy3473697c446d
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index 45a9c44bbd..4bdb1b1ebf 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -12,6 +12,8 @@
- `getStagePrompt()` export in taskSchedule for resolving pipeline stage-specific prompts
- Pipeline UI: collapsed row shows purple "2-stage" badge, expanded view shows stage flow visualization
- Pipeline UI: tabbed prompt viewer shows each stage's full prompt with stage name tabs
+- MortalLoom export now includes goals, reads actual custom drink/nicotine presets, and parallelizes all I/O
+- Export to MortalLoom button in MeatSpace Import tab
## Changed
diff --git a/client/src/components/meatspace/tabs/ImportTab.jsx b/client/src/components/meatspace/tabs/ImportTab.jsx
index 00bb09e16f..1435b741d0 100644
--- a/client/src/components/meatspace/tabs/ImportTab.jsx
+++ b/client/src/components/meatspace/tabs/ImportTab.jsx
@@ -1,5 +1,5 @@
import { useState, useRef, useEffect } from 'react';
-import { Upload, FileJson, HeartPulse, CheckCircle, AlertCircle } from 'lucide-react';
+import { Upload, Download, FileJson, HeartPulse, CheckCircle, AlertCircle } from 'lucide-react';
import * as api from '../../../services/api';
import socket from '../../../services/socket';
import BrailleSpinner from '../../BrailleSpinner';
@@ -100,8 +100,37 @@ export default function ImportTab({ onRefresh }) {
// Success handled via WebSocket health:xml:complete event
};
+ const handleMortalLoomExport = () => {
+ window.open('/api/meatspace/export/mortalloom', '_blank');
+ };
+
return (
<div className="space-y-6">
+ {/* MortalLoom Export */}
+ <div className="bg-port-card border border-port-border rounded-xl p-6">
+ <div className="flex items-center gap-2 mb-4">
+ <Download size={18} className="text-port-accent" />
+ <h3 className="text-sm font-medium text-gray-400 uppercase tracking-wider">
+ Export to MortalLoom
+ </h3>
+ </div>
+
+ <p className="text-sm text-gray-400 mb-2">
+ Export all MeatSpace data (goals, alcohol, nicotine, blood tests, eyes, body, epigenetics) as a MortalLoom-compatible JSON file.
+ </p>
+ <p className="text-xs text-gray-500 mb-4">
+ Apple Health data is not included — MortalLoom reads directly from Apple Health on your device.
+ </p>
+
+ <button
+ onClick={handleMortalLoomExport}
+ className="flex items-center gap-2 px-4 py-2 bg-port-accent text-white rounded-lg hover:bg-port-accent/80 transition-colors"
+ >
+ <Download size={16} />
+ Download MortalLoom Export
+ </button>
+ </div>
+
{/* Health Auto Export JSON Import */}
<div className="bg-port-card border border-port-border rounded-xl p-6">
<div className="flex items-center gap-2 mb-4">
diff --git a/server/routes/meatspace.js b/server/routes/meatspace.js
index 588a30e029..0fb16d7b86 100644
--- a/server/routes/meatspace.js
+++ b/server/routes/meatspace.js
@@ -49,6 +49,7 @@ import { generateLlmDrill, scoreLlmDrill } from '../services/meatspacePostLlm.js
import { getCachedDrill, triggerReplenish } from '../services/meatspacePostDrillCache.js';
import * as trainingService from '../services/meatspacePostTraining.js';
import * as calendarService from '../services/meatspaceCalendar.js';
+import { getGoals } from '../services/identity.js';
const router = Router();
@@ -863,14 +864,19 @@ router.delete('/life-events/:id', asyncHandler(async (req, res) => {
* Transforms PortOS daily-log + files into MortalLoom AppData schema.
*/
router.get('/export/mortalloom', asyncHandler(async (req, res) => {
- const config = await meatspaceService.getConfig();
- const bloodData = await healthService.getBloodTests();
- const epiData = await healthService.getEpigeneticTests();
- const eyeData = await healthService.getEyeExams();
- const bodyHistory = await healthService.getBodyHistory();
- const dailyLog = await readJSONFile(join(PATHS.meatspace, 'daily-log.json'), { entries: [] });
+ const [config, bloodData, epiData, eyeData, dailyLog, customDrinks, customNicotineProducts, goalsData] = await Promise.all([
+ meatspaceService.getConfig(),
+ healthService.getBloodTests(),
+ healthService.getEpigeneticTests(),
+ healthService.getEyeExams(),
+ readJSONFile(join(PATHS.meatspace, 'daily-log.json'), { entries: [] }),
+ alcoholService.getCustomDrinks(),
+ nicotineService.getCustomProducts(),
+ getGoals(),
+ ]);
+
+ const entries = dailyLog?.entries || [];
- // Profile
const profile = {
birthDate: config.birthDate || null,
biologicalSex: config.sex || null,
@@ -884,9 +890,8 @@ router.get('/export/mortalloom', asyncHandler(async (req, res) => {
},
};
- // Alcohol drinks - flatten daily log entries into individual drinks
const alcoholDrinks = [];
- for (const entry of (dailyLog?.entries || [])) {
+ for (const entry of entries) {
if (!entry.alcohol?.drinks) continue;
for (const drink of entry.alcohol.drinks) {
alcoholDrinks.push({
@@ -900,9 +905,8 @@ router.get('/export/mortalloom', asyncHandler(async (req, res) => {
}
}
- // Nicotine entries - flatten daily log
const nicotineEntries = [];
- for (const entry of (dailyLog?.entries || [])) {
+ for (const entry of entries) {
if (!entry.nicotine?.items) continue;
for (const item of entry.nicotine.items) {
nicotineEntries.push({
@@ -915,25 +919,21 @@ router.get('/export/mortalloom', asyncHandler(async (req, res) => {
}
}
- // Blood tests - PortOS stores markers flat on test object, MortalLoom nests under `markers`
const bloodTests = (bloodData?.tests || []).map(test => {
const { date, ...markers } = test;
- return {
- id: crypto.randomUUID(),
- date,
- markers,
- };
+ return { id: crypto.randomUUID(), date, markers };
});
- // Body entries from daily log
- const bodyEntries = bodyHistory.map(entry => ({
- id: crypto.randomUUID(),
- date: entry.date,
- weightLbs: entry.weightLbs ?? null,
- bodyFatPct: entry.fatPct ?? null,
- }));
+ // Derive body entries from daily log (avoids re-reading the file via getBodyHistory)
+ const bodyEntries = entries
+ .filter(e => e.body && Object.keys(e.body).length > 0)
+ .map(e => ({
+ id: crypto.randomUUID(),
+ date: e.date,
+ weightLbs: e.body.weightLbs ?? null,
+ bodyFatPct: e.body.fatPct ?? null,
+ }));
- // Epigenetic tests
const epigeneticTests = (epiData?.tests || []).map(test => ({
id: crypto.randomUUID(),
date: test.date,
@@ -943,7 +943,6 @@ router.get('/export/mortalloom', asyncHandler(async (req, res) => {
organScores: test.organScores ?? null,
}));
- // Eye exams
const eyeExams = (eyeData?.exams || []).map(exam => ({
id: crypto.randomUUID(),
date: exam.date,
@@ -955,19 +954,59 @@ router.get('/export/mortalloom', asyncHandler(async (req, res) => {
rightAxis: exam.rightAxis ?? null,
}));
- // Default alcohol presets (match MortalLoom defaults)
- const alcoholPresets = [
- { id: crypto.randomUUID(), name: 'Modelo Especial (12oz)', oz: 12, abv: 4.4 },
- { id: crypto.randomUUID(), name: 'Nitro Guinness (14.9oz)', oz: 14.9, abv: 4.2 },
- { id: crypto.randomUUID(), name: 'Old Fashioned (2oz)', oz: 2, abv: 40 },
- { id: crypto.randomUUID(), name: 'Guinness 0 (14.9oz)', oz: 14.9, abv: 0.4 },
- { id: crypto.randomUUID(), name: 'N/A Beer (12oz)', oz: 12, abv: 0.4 },
- ];
+ const alcoholPresets = customDrinks.map(d => ({
+ id: crypto.randomUUID(),
+ name: d.name,
+ oz: d.oz,
+ abv: d.abv,
+ }));
+
+ const nicotinePresets = customNicotineProducts.map(p => ({
+ id: crypto.randomUUID(),
+ name: p.name,
+ mgPerUnit: p.mgPerUnit,
+ }));
+
+ const GOAL_STATUS_MAP = { active: 'active', paused: 'paused', completed: 'completed', abandoned: 'abandoned', archived: 'completed' };
+ const goals = (goalsData?.goals || []).map(goal => {
+ const rawCheckIns = (goal.checkIns || []).map(ci => ({
+ id: crypto.randomUUID(),
+ date: ci.date?.slice(0, 10) ?? ci.timestamp?.slice(0, 10) ?? goal.createdAt?.slice(0, 10),
+ progressPct: ci.value ?? ci.progressPct ?? 0,
+ note: ci.note ?? '',
+ }));
+ // Fall back to progressHistory entries as check-ins when no explicit checkIns exist
+ const checkIns = rawCheckIns.length ? rawCheckIns : (goal.progressHistory || []).map(ph => ({
+ id: crypto.randomUUID(),
+ date: ph.date ?? ph.timestamp?.slice(0, 10),
+ progressPct: ph.value ?? 0,
+ note: '',
+ }));
+
+ const milestones = (goal.milestones || []).map(ms => ({
+ id: crypto.randomUUID(),
+ title: ms.title,
+ completed: !!ms.completedAt,
+ completedDate: ms.completedAt?.slice(0, 10) ?? null,
+ }));
- // Nicotine presets
- const nicotinePresets = [
- { id: crypto.randomUUID(), name: 'Stokes Pick (5mg)', mgPerUnit: 5 },
- ];
+ const status = GOAL_STATUS_MAP[goal.status] ?? 'active';
+ const priority = goal.urgency >= 0.7 ? 'high' : goal.urgency >= 0.4 ? 'medium' : 'low';
+
+ return {
+ id: crypto.randomUUID(),
+ title: goal.title,
+ notes: goal.description ?? '',
+ createdDate: goal.createdAt?.slice(0, 10) ?? null,
+ targetDate: goal.targetDate?.slice(0, 10) ?? null,
+ completedDate: status === 'completed' ? (goal.updatedAt?.slice(0, 10) ?? null) : null,
+ checkIns,
+ milestones,
+ checkInIntervalDays: 7,
+ status,
+ priority,
+ };
+ });
const exportData = {
profile,
@@ -979,6 +1018,7 @@ router.get('/export/mortalloom', asyncHandler(async (req, res) => {
eyeExams,
epigeneticTests,
bodyEntries,
+ goals,
};
res.setHeader('Content-Disposition', 'attachment; filename="MortalLoom-export.json"');