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(digital-twin): add Legacy Portrait export format

Adam Eivy70f48d65afe7
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.md
index aac9157450..d5909b7196 100644
--- a/.changelog/NEXT.md
+++ b/.changelog/NEXT.md
@@ -23,6 +23,7 @@
- Genome markers: summary dashboard with tappable status filter pills, "Attention Needed" section surfacing concerns first, category quick-jump dropdown, categories collapsed by default for mobile
- Genome markers: friendlier card UX with "What this means for you" framing, status-colored backgrounds, and renamed labels (Details, Your Notes, Learn More)
- Voice capture for Brain — microphone button on inbox uses Web Speech API to transcribe speech into thoughts
+- Legacy Portrait export format — comprehensive human-readable Markdown document consolidating identity docs, traits, chronotype, taste profile, genome, longevity, goals, autobiography, and social presence
## Changed
diff --git a/client/src/components/digital-twin/tabs/ExportTab.jsx b/client/src/components/digital-twin/tabs/ExportTab.jsx
index 6ff2ef166d..f7bbdffb4c 100644
--- a/client/src/components/digital-twin/tabs/ExportTab.jsx
+++ b/client/src/components/digital-twin/tabs/ExportTab.jsx
@@ -8,7 +8,8 @@ import {
FileJson,
Files,
RefreshCw,
- Eye
+ Eye,
+ BookOpen
} from 'lucide-react';
import * as api from '../../../services/api';
import toast from 'react-hot-toast';
@@ -87,7 +88,9 @@ export default function ExportTab({ onRefresh: _onRefresh }) {
: JSON.stringify(exportResult.content, null, 2);
const extension = selectedFormat === 'json' ? 'json' : 'md';
- const filename = `soul-export.${extension}`;
+ const filename = selectedFormat === 'legacy_portrait'
+ ? `legacy-portrait-${new Date().toISOString().slice(0, 10)}.md`
+ : `soul-export.${extension}`;
const blob = new Blob([content], { type: 'text/plain' });
const url = URL.createObjectURL(blob);
@@ -112,6 +115,8 @@ export default function ExportTab({ onRefresh: _onRefresh }) {
return FileJson;
case 'individual':
return Files;
+ case 'legacy_portrait':
+ return BookOpen;
default:
return FileText;
}
@@ -332,6 +337,14 @@ export default function ExportTab({ onRefresh: _onRefresh }) {
<p>3. Combine as needed for different use cases</p>
</div>
)}
+
+ {selectedFormat === 'legacy_portrait' && (
+ <div className="text-sm text-gray-400 space-y-2">
+ <p>1. Download the comprehensive identity portrait</p>
+ <p>2. Includes identity docs, traits, chronotype, taste, genome, goals, autobiography, and social presence</p>
+ <p>3. A durable, human-readable record — archive it, share it, or keep it as a time capsule</p>
+ </div>
+ )}
</div>
)}
</div>
diff --git a/server/services/digital-twin.js b/server/services/digital-twin.js
index 83978227b2..3bc0ff3dc0 100644
--- a/server/services/digital-twin.js
+++ b/server/services/digital-twin.js
@@ -22,6 +22,11 @@ import {
testHistoryEntrySchema
} from '../lib/digitalTwinValidation.js';
import { ensureDir, safeJSONParse, PATHS } from '../lib/fileUtils.js';
+import { getStories } from './autobiography.js';
+import { getGenomeSummary } from './genome.js';
+import { getTasteProfile } from './taste-questionnaire.js';
+import { getChronotype, getLongevity, getGoals } from './identity.js';
+import { getAllAccounts as getAllSocialAccounts } from './socialAccounts.js';
const DIGITAL_TWIN_DIR = PATHS.digitalTwin;
const META_FILE = join(DIGITAL_TWIN_DIR, 'meta.json');
@@ -1376,7 +1381,8 @@ export function getExportFormats() {
{ id: 'system_prompt', label: 'System Prompt', description: 'Combined markdown for direct injection' },
{ id: 'claude_md', label: 'CLAUDE.md', description: 'Format for Claude Code integration' },
{ id: 'json', label: 'JSON', description: 'Structured JSON for API integration' },
- { id: 'individual', label: 'Individual Files', description: 'Separate files for each document' }
+ { id: 'individual', label: 'Individual Files', description: 'Separate files for each document' },
+ { id: 'legacy_portrait', label: 'Legacy Portrait', description: 'Comprehensive human-readable identity document' }
];
}
@@ -1419,6 +1425,8 @@ export async function exportDigitalTwin(format, documentIds = null, includeDisab
return exportAsJson(documentsWithContent);
case 'individual':
return exportAsIndividual(documentsWithContent);
+ case 'legacy_portrait':
+ return exportAsLegacyPortrait(documentsWithContent);
default:
throw new Error(`Unknown export format: ${format}`);
}
@@ -1501,6 +1509,148 @@ function exportAsIndividual(docs) {
};
}
+async function exportAsLegacyPortrait(docs) {
+ // Gather data from all identity domains in parallel
+ const [stories, genomeSummary, tasteProfile, chronotype, longevity, goalsData, socialAccounts, traits] = await Promise.all([
+ getStories().catch(() => []),
+ getGenomeSummary().catch(() => ({ uploaded: false })),
+ getTasteProfile().catch(() => ({ sections: [] })),
+ getChronotype().catch(() => null),
+ getLongevity().catch(() => null),
+ getGoals().catch(() => ({ goals: [] })),
+ getAllSocialAccounts().catch(() => []),
+ getTraits()
+ ]);
+
+ const sections = [];
+ const exportDate = new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' });
+
+ sections.push(`# Legacy Portrait\n\n*Exported ${exportDate}*\n\nThis document is a comprehensive portrait of identity, values, knowledge, and life story — preserved as a human-readable record.\n`);
+
+ // --- Digital Twin Documents ---
+ if (docs.length > 0) {
+ sections.push('---\n\n## Identity & Values\n');
+ for (const doc of docs) {
+ sections.push(doc.content);
+ }
+ }
+
+ // --- Personality Traits ---
+ if (traits?.dimensions) {
+ sections.push('---\n\n## Personality Traits\n');
+ const dims = traits.dimensions;
+ const traitLines = Object.entries(dims)
+ .filter(([, v]) => v?.score != null)
+ .map(([key, v]) => `- **${formatTraitName(key)}**: ${v.score}/100${v.label ? ` (${v.label})` : ''}`);
+ if (traitLines.length > 0) {
+ sections.push(traitLines.join('\n'));
+ }
+ if (traits.summary) {
+ sections.push(`\n${traits.summary}`);
+ }
+ }
+
+ // --- Chronotype ---
+ if (chronotype?.type) {
+ sections.push('---\n\n## Chronotype\n');
+ sections.push(`**Type**: ${chronotype.type}${chronotype.confidence ? ` (${Math.round(chronotype.confidence * 100)}% confidence)` : ''}`);
+ if (chronotype.schedule) {
+ const s = chronotype.schedule;
+ sections.push(`- Wake: ${s.wakeTime || 'unknown'} | Sleep: ${s.sleepTime || 'unknown'}`);
+ if (s.peakFocusStart && s.peakFocusEnd) {
+ sections.push(`- Peak focus: ${s.peakFocusStart}–${s.peakFocusEnd}`);
+ }
+ }
+ }
+
+ // --- Taste Profile ---
+ const completedSections = (tasteProfile.sections || tasteProfile)?.filter?.(s => s.status === 'complete') || [];
+ if (completedSections.length > 0) {
+ sections.push('---\n\n## Taste Profile\n');
+ for (const section of completedSections) {
+ sections.push(`### ${section.label}\n`);
+ if (section.summary) {
+ sections.push(section.summary);
+ }
+ }
+ }
+
+ // --- Genome ---
+ if (genomeSummary?.uploaded) {
+ sections.push('---\n\n## Genome\n');
+ const lines = [`- **SNPs analyzed**: ${genomeSummary.snpCount?.toLocaleString() || 'unknown'}`];
+ if (genomeSummary.markerCount) lines.push(`- **Markers tracked**: ${genomeSummary.markerCount}`);
+ if (genomeSummary.statusCounts) {
+ const c = genomeSummary.statusCounts;
+ lines.push(`- Beneficial: ${c.beneficial || 0} | Typical: ${c.typical || 0} | Concern: ${c.concern || 0}`);
+ }
+ sections.push(lines.join('\n'));
+ }
+
+ // --- Longevity ---
+ if (longevity?.estimatedLifeExpectancy) {
+ sections.push('---\n\n## Longevity\n');
+ sections.push(`- **Estimated life expectancy**: ${longevity.estimatedLifeExpectancy} years`);
+ if (longevity.baselineLifeExpectancy) {
+ sections.push(`- **Baseline**: ${longevity.baselineLifeExpectancy} years`);
+ }
+ }
+
+ // --- Goals ---
+ const goals = goalsData?.goals || [];
+ if (goals.length > 0) {
+ sections.push('---\n\n## Life Goals\n');
+ const activeGoals = goals.filter(g => g.status !== 'abandoned');
+ for (const goal of activeGoals) {
+ const status = goal.status === 'completed' ? ' [completed]' : goal.progress ? ` (${goal.progress}%)` : '';
+ sections.push(`- **${goal.title}**${status}${goal.description ? `: ${goal.description}` : ''}`);
+ }
+ }
+
+ // --- Autobiography ---
+ if (stories.length > 0) {
+ sections.push('---\n\n## Life Stories\n');
+ // Sort by theme, then chronologically
+ const sortedStories = [...stories].sort((a, b) => (a.themeId || '').localeCompare(b.themeId || '') || new Date(a.createdAt) - new Date(b.createdAt));
+ let currentTheme = null;
+ for (const story of sortedStories) {
+ if (story.themeId !== currentTheme) {
+ currentTheme = story.themeId;
+ const themeLabel = currentTheme ? currentTheme.charAt(0).toUpperCase() + currentTheme.slice(1).replace(/_/g, ' ') : 'Miscellaneous';
+ sections.push(`\n### ${themeLabel}\n`);
+ }
+ if (story.prompt) sections.push(`> *${story.prompt}*\n`);
+ sections.push(story.content);
+ }
+ }
+
+ // --- Social Presence ---
+ if (socialAccounts.length > 0) {
+ sections.push('---\n\n## Social Presence\n');
+ for (const account of socialAccounts) {
+ const url = account.url ? ` — ${account.url}` : '';
+ sections.push(`- **${account.platform || account.name}**: ${account.username || account.handle || '(linked)'}${url}`);
+ }
+ }
+
+ sections.push('\n---\n\n*This portrait was generated by PortOS as a durable record of identity, knowledge, and life story.*');
+
+ const content = sections.join('\n\n');
+
+ return {
+ format: 'legacy_portrait',
+ content,
+ documentCount: docs.length,
+ storyCount: stories.length,
+ goalCount: goals.length,
+ tokenEstimate: Math.ceil(content.length / 4)
+ };
+}
+
+function formatTraitName(key) {
+ return key.replace(/([A-Z])/g, ' $1').replace(/^./, c => c.toUpperCase()).trim();
+}
+
// =============================================================================
// COS INTEGRATION
// =============================================================================
diff --git a/server/services/digital-twin.test.js b/server/services/digital-twin.test.js
index 6f61a59457..7b9a606229 100644
--- a/server/services/digital-twin.test.js
+++ b/server/services/digital-twin.test.js
@@ -46,7 +46,30 @@ vi.mock('../lib/fileUtils.js', () => ({
const parsed = JSON.parse(str);
return parsed;
}),
- PATHS: { digitalTwin: '/tmp/test/digital-twin' }
+ PATHS: { digitalTwin: '/tmp/test/digital-twin' },
+ readJSONFile: vi.fn(() => null)
+}));
+
+vi.mock('./autobiography.js', () => ({
+ getStories: vi.fn(() => [])
+}));
+
+vi.mock('./genome.js', () => ({
+ getGenomeSummary: vi.fn(() => ({ uploaded: false }))
+}));
+
+vi.mock('./taste-questionnaire.js', () => ({
+ getTasteProfile: vi.fn(() => ({ sections: [] }))
+}));
+
+vi.mock('./identity.js', () => ({
+ getChronotype: vi.fn(() => null),
+ getLongevity: vi.fn(() => null),
+ getGoals: vi.fn(() => ({ goals: [] }))
+}));
+
+vi.mock('./socialAccounts.js', () => ({
+ getAllAccounts: vi.fn(() => [])
}));
// ============================================================================
@@ -832,12 +855,13 @@ Should mention core values.
describe('getExportFormats', () => {
it('should return all export formats', () => {
const formats = getExportFormats();
- expect(formats).toHaveLength(4);
+ expect(formats).toHaveLength(5);
const ids = formats.map(f => f.id);
expect(ids).toContain('system_prompt');
expect(ids).toContain('claude_md');
expect(ids).toContain('json');
expect(ids).toContain('individual');
+ expect(ids).toContain('legacy_portrait');
});
});