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: add personalized taste prompting & 2 new taste sections (M42 P2.5)

Adam Eivyec28813fae96
diff --git a/.changelog/v1.7.x.md b/.changelog/v1.7.x.md
new file mode 100644
index 0000000000..c126891752
--- /dev/null
+++ b/.changelog/v1.7.x.md
@@ -0,0 +1,22 @@
+# Release v1.7.x - Changelog
+
+Released: YYYY-MM-DD
+
+## Overview
+
+Personalized taste prompting and expanded aesthetic domains for the Digital Twin.
+
+## Features
+
+### Personalized Taste Prompting (M42 P2.5)
+- Added LLM-generated personalized follow-up questions that reference identity documents (BOOKS.md, AUDIO.md, CREATIVE.md, PREFERENCES.md, PERSONALITY.md, enrichment answers, existing taste responses)
+- "Go Deeper" button appears after a section's static questions are complete — generates a personalized question using identity context and selected AI provider
+- Personalized questions shown with distinct purple "Personalized — referencing your identity" badge
+- Answers to personalized questions stored with `source: 'personalized'` metadata and the generated question text for audit trail
+- Identity context aggregation reads up to 2000 chars from each identity doc, cross-section taste responses, and enrichment progress to build a ~4000 char context window for the LLM
+- New API endpoint: `POST /api/digital-twin/taste/:section/personalized-question`
+
+### New Taste Sections: Fashion & Digital
+- **Fashion & Texture** (`fashion`): material/fabric preferences, color wardrobe, formality spectrum, style identity, anti-fashion positions — with follow-ups for texture sensitivity, natural materials, minimalist wardrobe, color expression, and vintage aesthetics
+- **Digital & Interface** (`digital`): dark/light mode preferences, information density, animation tolerance, tool aesthetics, notification/attention style — with follow-ups for dark mode specifics, minimal vs dense UI, software craftsmanship, and digital focus management
+- Total taste sections expanded from 5 to 7
diff --git a/PLAN.md b/PLAN.md
index 8cb37ca4f0..558bd25035 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -159,7 +159,7 @@ All 10 audit items (S1–S10) from the 2025-02-19 security audit have been resol
## Next Actions
1. ~~**M42 P1: Identity Orchestrator & Chronotype**~~ ✅ - Identity service, chronotype derivation from genome sleep/caffeine markers, 4 API endpoints, 36 tests
-2. **M42 P2.5: Personalized Taste Prompting** - Enhance TasteTab with twin-aware follow-up questions using identity context from existing documents
+2. ~~**M42 P2.5: Personalized Taste Prompting**~~ ✅ - LLM-personalized follow-ups using identity context, 2 new taste sections (Fashion & Digital), "Go Deeper" flow
3. **M7: App Templates** - Implement template management UI and app scaffolding from templates
4. **M34 P3: Behavioral Feedback Loop** - Add "sounds like me" response validation and adaptive weighting
5. **M42 P3: Mortality-Aware Goal Tracking** - Birth date + genome longevity markers for urgency-scored goals
diff --git a/client/src/components/digital-twin/tabs/TasteTab.jsx b/client/src/components/digital-twin/tabs/TasteTab.jsx
index bf055ef28e..3f4c7b7798 100644
--- a/client/src/components/digital-twin/tabs/TasteTab.jsx
+++ b/client/src/components/digital-twin/tabs/TasteTab.jsx
@@ -5,6 +5,8 @@ import {
Music,
Building,
UtensilsCrossed,
+ Shirt,
+ Monitor,
ChevronRight,
ArrowLeft,
Send,
@@ -15,7 +17,8 @@ import {
RotateCcw,
Eye,
ChevronDown,
- ChevronUp
+ ChevronUp,
+ Telescope
} from 'lucide-react';
import * as api from '../../../services/api';
import toast from 'react-hot-toast';
@@ -25,7 +28,9 @@ const SECTION_ICONS = {
music: Music,
visual_art: Palette,
architecture: Building,
- food: UtensilsCrossed
+ food: UtensilsCrossed,
+ fashion: Shirt,
+ digital: Monitor
};
const SECTION_COLORS = {
@@ -33,7 +38,9 @@ const SECTION_COLORS = {
music: 'green',
visual_art: 'violet',
architecture: 'amber',
- food: 'orange'
+ food: 'orange',
+ fashion: 'pink',
+ digital: 'cyan'
};
export default function TasteTab({ onRefresh }) {
@@ -57,6 +64,10 @@ export default function TasteTab({ onRefresh }) {
const [reviewResponses, setReviewResponses] = useState([]);
const [loadingReview, setLoadingReview] = useState(false);
+ // Personalized question state
+ const [personalizedQuestion, setPersonalizedQuestion] = useState(null);
+ const [loadingPersonalized, setLoadingPersonalized] = useState(false);
+
// Expanded summaries
const [expandedSummary, setExpandedSummary] = useState(null);
@@ -93,10 +104,16 @@ export default function TasteTab({ onRefresh }) {
if (!answer.trim() || !currentQuestion) return;
setSubmitting(true);
+ const meta = currentQuestion.isPersonalized ? {
+ source: 'personalized',
+ generatedQuestion: currentQuestion.text,
+ identityContextUsed: currentQuestion.identityContextUsed
+ } : {};
const result = await api.submitTasteAnswer(
activeSection,
currentQuestion.questionId,
- answer.trim()
+ answer.trim(),
+ meta
).catch(() => null);
if (!result) {
@@ -108,8 +125,11 @@ export default function TasteTab({ onRefresh }) {
toast.success('Response saved');
setAnswer('');
- // Use the next question returned inline from the submit response
- if (result.nextQuestion) {
+ // If we just answered a personalized question, clear it and show section complete
+ if (currentQuestion.isPersonalized) {
+ setPersonalizedQuestion(null);
+ setCurrentQuestion(null);
+ } else if (result.nextQuestion) {
setCurrentQuestion(result.nextQuestion);
} else {
setCurrentQuestion(null);
@@ -120,12 +140,37 @@ export default function TasteTab({ onRefresh }) {
onRefresh?.();
};
+ const handleGoDeeper = async () => {
+ if (!selectedProvider) {
+ toast.error('Select a provider first');
+ return;
+ }
+ setLoadingPersonalized(true);
+ const question = await api.getPersonalizedTasteQuestion(
+ activeSection,
+ selectedProvider.providerId,
+ selectedProvider.model
+ ).catch(() => null);
+
+ if (!question) {
+ toast('No personalized question available — try completing more identity documents', { icon: '⚠️' });
+ setLoadingPersonalized(false);
+ return;
+ }
+
+ setPersonalizedQuestion(question);
+ setCurrentQuestion(question);
+ setAnswer('');
+ setLoadingPersonalized(false);
+ };
+
const exitSection = () => {
setActiveSection(null);
setCurrentQuestion(null);
setAnswer('');
setReviewSection(null);
setReviewResponses([]);
+ setPersonalizedQuestion(null);
};
const handleReviewSection = async (sectionId) => {
@@ -229,11 +274,13 @@ export default function TasteTab({ onRefresh }) {
) : (
<div className="space-y-4">
{reviewResponses.map((r, i) => (
- <div key={i} className="bg-port-card rounded-lg border border-port-border p-4">
+ <div key={i} className={`bg-port-card rounded-lg border ${r.isPersonalized ? 'border-purple-500/30' : 'border-port-border'} p-4`}>
<div className="flex items-start gap-2 mb-2">
- {r.isFollowUp && (
+ {r.isPersonalized ? (
+ <span className="text-xs px-2 py-0.5 bg-purple-500/20 text-purple-400 rounded">personalized</span>
+ ) : r.isFollowUp ? (
<span className="text-xs px-2 py-0.5 bg-port-accent/20 text-port-accent rounded">follow-up</span>
- )}
+ ) : null}
<p className="text-sm text-gray-400">{r.questionText}</p>
</div>
<p className="text-white whitespace-pre-wrap">{r.answer}</p>
@@ -280,7 +327,7 @@ export default function TasteTab({ onRefresh }) {
const color = SECTION_COLORS[activeSection] || 'blue';
// Section complete
- if (!currentQuestion && !loadingQuestion) {
+ if (!currentQuestion && !loadingQuestion && !loadingPersonalized) {
return (
<div className="max-w-2xl mx-auto px-1">
<div className="mb-6">
@@ -305,6 +352,14 @@ export default function TasteTab({ onRefresh }) {
</div>
</div>
<div className="flex flex-col sm:flex-row gap-3">
+ <button
+ onClick={handleGoDeeper}
+ disabled={loadingPersonalized || !selectedProvider}
+ className="flex items-center justify-center gap-2 px-4 py-3 min-h-[44px] bg-purple-600 text-white rounded-lg text-sm hover:bg-purple-500 disabled:opacity-50"
+ >
+ {loadingPersonalized ? <RefreshCw className="w-4 h-4 animate-spin" /> : <Telescope size={16} />}
+ Go Deeper
+ </button>
<button
onClick={() => handleReviewSection(activeSection)}
className="flex items-center justify-center gap-2 px-4 py-3 min-h-[44px] bg-port-card border border-port-border text-white rounded-lg text-sm hover:border-port-accent"
@@ -351,7 +406,7 @@ export default function TasteTab({ onRefresh }) {
<div className="mt-4">
<div className="flex items-center justify-between text-sm mb-1">
<span className="text-gray-400">
- {currentQuestion?.isFollowUp ? 'Follow-up question' : `Question ${currentQuestion?.progress?.current || 1} of ${currentQuestion?.progress?.coreTotal || '?'}`}
+ {currentQuestion?.isPersonalized ? 'Personalized deep-dive' : currentQuestion?.isFollowUp ? 'Follow-up question' : `Question ${currentQuestion?.progress?.current || 1} of ${currentQuestion?.progress?.coreTotal || '?'}`}
</span>
<span className="text-gray-400">{section?.progress?.percentage || 0}% core complete</span>
</div>
@@ -364,16 +419,25 @@ export default function TasteTab({ onRefresh }) {
</div>
</div>
- {loadingQuestion ? (
- <div className="flex items-center justify-center h-48">
+ {loadingQuestion || loadingPersonalized ? (
+ <div className="flex flex-col items-center justify-center h-48 gap-3">
<RefreshCw className="w-6 h-6 text-port-accent animate-spin" />
+ {loadingPersonalized && (
+ <span className="text-sm text-gray-400">Generating personalized question...</span>
+ )}
</div>
) : (
- <div className="bg-port-card rounded-lg border border-port-border p-6">
+ <div className={`bg-port-card rounded-lg border ${currentQuestion?.isPersonalized ? 'border-purple-500/30' : 'border-port-border'} p-6`}>
<div className="mb-6">
- <span className="text-xs text-gray-500 uppercase tracking-wider">
- {currentQuestion?.isFollowUp ? 'Follow-up — based on your previous answer' : 'Core Question'}
- </span>
+ {currentQuestion?.isPersonalized ? (
+ <span className="text-xs px-2 py-0.5 bg-purple-500/20 text-purple-400 rounded uppercase tracking-wider">
+ Personalized — referencing your identity
+ </span>
+ ) : (
+ <span className="text-xs text-gray-500 uppercase tracking-wider">
+ {currentQuestion?.isFollowUp ? 'Follow-up — based on your previous answer' : 'Core Question'}
+ </span>
+ )}
<h3 className="text-xl text-white mt-2">{currentQuestion?.text}</h3>
</div>
@@ -392,27 +456,41 @@ export default function TasteTab({ onRefresh }) {
</div>
<div className="flex flex-col-reverse sm:flex-row items-stretch sm:items-center justify-between gap-3">
- <button
- onClick={() => {
- // Skip current question by submitting empty — move to next
- setAnswer('');
- setLoadingQuestion(true);
- api.getTasteNextQuestion(activeSection).then(q => {
- // If same question returned (can't skip core), just clear loading
- if (q?.questionId === currentQuestion?.questionId) {
- toast('Core questions cannot be skipped', { icon: '⚠️' });
- } else {
- setCurrentQuestion(q);
- }
- setLoadingQuestion(false);
- }).catch(() => setLoadingQuestion(false));
- }}
- disabled={!currentQuestion?.isFollowUp}
- className="flex items-center justify-center gap-2 px-4 py-3 min-h-[44px] text-gray-400 hover:text-white transition-colors disabled:opacity-30 disabled:cursor-not-allowed"
- >
- <SkipForward size={18} />
- Skip
- </button>
+ {currentQuestion?.isPersonalized ? (
+ <button
+ onClick={() => {
+ setCurrentQuestion(null);
+ setPersonalizedQuestion(null);
+ setAnswer('');
+ }}
+ className="flex items-center justify-center gap-2 px-4 py-3 min-h-[44px] text-gray-400 hover:text-white transition-colors"
+ >
+ <ArrowLeft size={18} />
+ Done exploring
+ </button>
+ ) : (
+ <button
+ onClick={() => {
+ // Skip current question by submitting empty — move to next
+ setAnswer('');
+ setLoadingQuestion(true);
+ api.getTasteNextQuestion(activeSection).then(q => {
+ // If same question returned (can't skip core), just clear loading
+ if (q?.questionId === currentQuestion?.questionId) {
+ toast('Core questions cannot be skipped', { icon: '⚠️' });
+ } else {
+ setCurrentQuestion(q);
+ }
+ setLoadingQuestion(false);
+ }).catch(() => setLoadingQuestion(false));
+ }}
+ disabled={!currentQuestion?.isFollowUp}
+ className="flex items-center justify-center gap-2 px-4 py-3 min-h-[44px] text-gray-400 hover:text-white transition-colors disabled:opacity-30 disabled:cursor-not-allowed"
+ >
+ <SkipForward size={18} />
+ Skip
+ </button>
+ )}
<button
onClick={submitAnswer}
@@ -449,7 +527,7 @@ export default function TasteTab({ onRefresh }) {
<h2 className="text-lg font-semibold text-white">Aesthetic Taste Profile</h2>
</div>
<span className="text-gray-400">
- {profile?.completedCount || 0}/{profile?.totalSections || 5} sections complete
+ {profile?.completedCount || 0}/{profile?.totalSections || 7} sections complete
</span>
</div>
diff --git a/client/src/services/api.js b/client/src/services/api.js
index d518870246..82c9035f1c 100644
--- a/client/src/services/api.js
+++ b/client/src/services/api.js
@@ -1085,15 +1085,20 @@ export const saveDigitalTwinImport = (source, suggestedDoc) => request('/digital
export const getTasteProfile = () => request('/digital-twin/taste');
export const getTasteSections = () => request('/digital-twin/taste/sections');
export const getTasteNextQuestion = (section) => request(`/digital-twin/taste/${section}/next`);
-export const submitTasteAnswer = (section, questionId, answer) => request('/digital-twin/taste/answer', {
+export const submitTasteAnswer = (section, questionId, answer, meta = {}) => request('/digital-twin/taste/answer', {
method: 'POST',
- body: JSON.stringify({ section, questionId, answer })
+ body: JSON.stringify({ section, questionId, answer, ...meta })
});
export const getTasteSectionResponses = (section) => request(`/digital-twin/taste/${section}/responses`);
export const generateTasteSummary = (providerId, model, section) => request('/digital-twin/taste/summary', {
method: 'POST',
body: JSON.stringify({ providerId, model, ...(section ? { section } : {}) })
});
+export const getPersonalizedTasteQuestion = (section, providerId, model) =>
+ request(`/digital-twin/taste/${section}/personalized-question`, {
+ method: 'POST',
+ body: JSON.stringify({ providerId, model })
+ });
export const resetTasteSection = (section) => request(`/digital-twin/taste/${section}`, {
method: 'DELETE'
});
diff --git a/package-lock.json b/package-lock.json
index eb1e1ca726..51d837baf1 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "portos",
- "version": "1.7.0",
+ "version": "1.7.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "portos",
- "version": "1.7.0",
+ "version": "1.7.1",
"license": "MIT",
"dependencies": {
"express": "^4.21.2",
diff --git a/package.json b/package.json
index 9c026530af..3962b43f7c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "portos",
- "version": "1.7.0",
+ "version": "1.7.1",
"private": true,
"description": "Local dev machine App OS portal",
"author": "Adam Eivy (@antic|@atomantic)",
diff --git a/server/lib/digitalTwinValidation.js b/server/lib/digitalTwinValidation.js
index 187dead62d..7db795566b 100644
--- a/server/lib/digitalTwinValidation.js
+++ b/server/lib/digitalTwinValidation.js
@@ -403,13 +403,21 @@ export const importAnalysisResultSchema = z.object({
// --- Taste Questionnaire Schemas ---
export const tasteSectionEnum = z.enum([
- 'movies', 'music', 'visual_art', 'architecture', 'food'
+ 'movies', 'music', 'visual_art', 'architecture', 'food', 'fashion', 'digital'
]);
export const tasteAnswerInputSchema = z.object({
section: tasteSectionEnum,
questionId: z.string().min(1),
- answer: z.string().min(1).max(10000)
+ answer: z.string().min(1).max(10000),
+ source: z.enum(['core', 'follow_up', 'personalized']).optional(),
+ generatedQuestion: z.string().optional(),
+ identityContextUsed: z.array(z.string()).optional()
+});
+
+export const tastePersonalizedQuestionInputSchema = z.object({
+ providerId: z.string().min(1).optional(),
+ model: z.string().min(1).optional()
});
export const tasteSummaryInputSchema = z.object({
diff --git a/server/routes/digital-twin.js b/server/routes/digital-twin.js
index eb32a6c006..c029ee73f0 100644
--- a/server/routes/digital-twin.js
+++ b/server/routes/digital-twin.js
@@ -37,7 +37,8 @@ import {
analyzeAssessmentInputSchema,
tasteAnswerInputSchema,
tasteSummaryInputSchema,
- tasteSectionEnum
+ tasteSectionEnum,
+ tastePersonalizedQuestionInputSchema
} from '../lib/digitalTwinValidation.js';
const router = Router();
@@ -520,8 +521,8 @@ router.get('/taste/:section/next', asyncHandler(async (req, res) => {
* Submit an answer for a taste question
*/
router.post('/taste/answer', asyncHandler(async (req, res) => {
- const { section, questionId, answer } = validateRequest(tasteAnswerInputSchema, req.body);
- const result = await tasteService.submitAnswer(section, questionId, answer);
+ const { section, questionId, answer, source, generatedQuestion, identityContextUsed } = validateRequest(tasteAnswerInputSchema, req.body);
+ const result = await tasteService.submitAnswer(section, questionId, answer, { source, generatedQuestion, identityContextUsed });
res.json(result);
}));
@@ -555,6 +556,23 @@ router.post('/taste/summary', asyncHandler(async (req, res) => {
res.json(result);
}));
+/**
+ * POST /api/digital-twin/taste/:section/personalized-question
+ * Generate a personalized follow-up question using identity context
+ */
+router.post('/taste/:section/personalized-question', asyncHandler(async (req, res) => {
+ const parsed = tasteSectionEnum.safeParse(req.params.section);
+ if (!parsed.success) {
+ throw new ServerError(`Invalid taste section: ${req.params.section}`, {
+ status: 400,
+ code: 'VALIDATION_ERROR'
+ });
+ }
+ const { providerId, model } = validateRequest(tastePersonalizedQuestionInputSchema, req.body);
+ const question = await tasteService.generatePersonalizedTasteQuestion(parsed.data, providerId, model);
+ res.json(question);
+}));
+
/**
* DELETE /api/digital-twin/taste/:section
* Reset a taste section
diff --git a/server/services/taste-questionnaire.js b/server/services/taste-questionnaire.js
index 5a55a9516b..d089a75024 100644
--- a/server/services/taste-questionnaire.js
+++ b/server/services/taste-questionnaire.js
@@ -256,6 +256,119 @@ export const TASTE_SECTIONS = {
followUps: []
}
]
+ },
+ fashion: {
+ label: 'Fashion & Texture',
+ description: 'Material preferences, tactile comfort, color wardrobe, style identity',
+ icon: 'Shirt',
+ color: 'pink',
+ questions: [
+ {
+ id: 'fashion-core-1',
+ text: 'What materials or fabrics do you gravitate toward? Think about what feels right against your skin, what you reach for instinctively — cotton, linen, wool, synthetics, leather?',
+ type: 'text',
+ followUps: [
+ {
+ id: 'fashion-fu-texture',
+ trigger: 'texture|soft|rough|smooth|feel|tactile|touch|sensory',
+ text: 'Tactile experience matters to you. Do you choose clothing primarily by how it feels, or is visual appearance more important? Are there textures you absolutely cannot tolerate?'
+ },
+ {
+ id: 'fashion-fu-natural',
+ trigger: 'natural|organic|linen|cotton|wool|silk|sustainable|eco',
+ text: 'You lean toward natural materials. Is this about comfort, ethics, aesthetics, or all three? Do you actively avoid synthetics?'
+ }
+ ]
+ },
+ {
+ id: 'fashion-core-2',
+ text: 'Describe your color wardrobe — what colors dominate your closet? Where do you fall on the formality spectrum, from athleisure to tailored?',
+ type: 'text',
+ followUps: [
+ {
+ id: 'fashion-fu-minimal',
+ trigger: 'minimalist|capsule|neutral|black|simple|uniform|same',
+ text: 'You favor a minimalist wardrobe approach. Is this about decision fatigue, aesthetic conviction, or practicality? Do you have a signature look or uniform?'
+ },
+ {
+ id: 'fashion-fu-color',
+ trigger: 'color|bright|pattern|print|bold|statement|express',
+ text: 'You use color expressively. Do you dress for mood, season, or self-expression? Are there colors you associate with specific feelings or identities?'
+ }
+ ]
+ },
+ {
+ id: 'fashion-core-3',
+ text: 'How would you describe your style identity? What fashion movements, eras, or anti-fashion positions resonate with you? What do you refuse to wear?',
+ type: 'text',
+ followUps: [
+ {
+ id: 'fashion-fu-vintage',
+ trigger: 'vintage|retro|thrift|secondhand|era|classic|timeless',
+ text: 'You connect with vintage or classic style. Is there a specific era that defines your aesthetic? Do you actively seek out vintage pieces, or is it more about the timeless quality?'
+ }
+ ]
+ }
+ ]
+ },
+ digital: {
+ label: 'Digital & Interface',
+ description: 'Dark/light mode, information density, tool aesthetics, digital environment preferences',
+ icon: 'Monitor',
+ color: 'cyan',
+ questions: [
+ {
+ id: 'digital-core-1',
+ text: 'Dark mode or light mode — and why? How do you feel about information density on screen? Do you prefer spacious layouts or packed dashboards? What about animations and transitions?',
+ type: 'text',
+ followUps: [
+ {
+ id: 'digital-fu-darkmode',
+ trigger: 'dark mode|dark theme|dark|night|black background|oled',
+ text: 'You prefer dark interfaces. Is it about eye comfort, aesthetics, or focus? Do you prefer true black (#000) or dark gray? How do you feel about pure white text on dark backgrounds vs softer contrast?'
+ },
+ {
+ id: 'digital-fu-minimal',
+ trigger: 'minimal|clean|simple|spacious|breathing room|whitespace',
+ text: 'You value visual breathing room. Does this extend to your desktop, file organization, and browser tabs? Or is the preference purely about UI design?'
+ },
+ {
+ id: 'digital-fu-dense',
+ trigger: 'dense|packed|data|dashboard|information|everything visible|power user',
+ text: 'You like information-dense interfaces. Is this about efficiency, control, or the satisfaction of seeing everything at once? Name a tool that gets information density right for you.'
+ }
+ ]
+ },
+ {
+ id: 'digital-core-2',
+ text: 'What software tools feel genuinely good to use — not just functional, but aesthetically satisfying? What makes them feel that way?',
+ type: 'text',
+ followUps: [
+ {
+ id: 'digital-fu-craft',
+ trigger: 'craft|polish|attention to detail|animation|smooth|responsive|fast',
+ text: 'You appreciate software craftsmanship. How much does performance (speed, responsiveness) factor into your aesthetic experience of software vs visual design alone?'
+ },
+ {
+ id: 'digital-fu-cluttered',
+ trigger: 'cluttered|bloated|heavy|slow|electron|ugly|hate',
+ text: 'You have strong negative reactions to certain software aesthetics. Is it the visual clutter, the performance overhead, or the feeling of disrespect for your attention?'
+ }
+ ]
+ },
+ {
+ id: 'digital-core-3',
+ text: 'Describe your ideal notification and attention style. How do you manage digital interruptions? What does your ideal digital environment look like in terms of focus and distraction?',
+ type: 'text',
+ followUps: [
+ {
+ id: 'digital-fu-focus',
+ trigger: 'focus|distraction|notification|dnd|do not disturb|quiet|silence|zen',
+ text: 'You actively manage digital attention. Do you use specific tools or systems for this? Is your approach about discipline, environment design, or both?'
+ }
+ ]
+ }
+ ]
}
};
@@ -416,7 +529,7 @@ export async function getNextQuestion(sectionId) {
/**
* Submit an answer for a taste question.
*/
-export async function submitAnswer(sectionId, questionId, answer) {
+export async function submitAnswer(sectionId, questionId, answer, { source, generatedQuestion, identityContextUsed } = {}) {
const config = TASTE_SECTIONS[sectionId];
if (!config) throw new Error(`Unknown taste section: ${sectionId}`);
@@ -430,12 +543,17 @@ export async function submitAnswer(sectionId, questionId, answer) {
if (existing) {
existing.answer = answer;
existing.updatedAt = now();
+ if (source) existing.source = source;
} else {
- profile.sections[sectionId].responses.push({
+ const responseEntry = {
questionId,
answer,
answeredAt: now()
- });
+ };
+ if (source) responseEntry.source = source;
+ if (generatedQuestion) responseEntry.generatedQuestion = generatedQuestion;
+ if (identityContextUsed) responseEntry.identityContextUsed = identityContextUsed;
+ profile.sections[sectionId].responses.push(responseEntry);
}
if (!profile.createdAt) profile.createdAt = now();
@@ -657,11 +775,13 @@ export async function getSectionResponses(sectionId) {
return sectionData.responses.map(r => {
const qDef = findQuestionDef(sectionId, r.questionId);
+ const isPersonalized = r.questionId.includes('-p25-') || r.source === 'personalized';
return {
questionId: r.questionId,
- questionText: qDef?.text || r.questionId,
+ questionText: isPersonalized ? (r.generatedQuestion || r.questionId) : (qDef?.text || r.questionId),
answer: r.answer,
isFollowUp: r.questionId.includes('-fu-'),
+ isPersonalized,
answeredAt: r.answeredAt
};
});
@@ -680,6 +800,137 @@ export async function resetSection(sectionId) {
return { section: sectionId, status: 'reset' };
}
+// =============================================================================
+// PERSONALIZED QUESTION GENERATION
+// =============================================================================
+
+const IDENTITY_DOCS = ['BOOKS.md', 'AUDIO.md', 'CREATIVE.md', 'PREFERENCES.md', 'PERSONALITY.md'];
+const MAX_CONTEXT_CHARS = 4000;
+
+/**
+ * Aggregate identity context from digital twin documents for personalized prompting.
+ */
+async function aggregateIdentityContext(sectionId) {
+ const contextParts = [];
+ const sourcesUsed = [];
+
+ // Read identity documents (first ~2000 chars each)
+ for (const docName of IDENTITY_DOCS) {
+ const docPath = join(DIGITAL_TWIN_DIR, docName);
+ if (!existsSync(docPath)) continue;
+ const content = await readFile(docPath, 'utf-8');
+ if (content.trim().length > 0) {
+ contextParts.push(`## ${docName}\n${content.slice(0, 2000)}`);
+ sourcesUsed.push(docName);
+ }
+ }
+
+ // Read enrichment answers from meta.json
+ const metaPath = join(DIGITAL_TWIN_DIR, 'meta.json');
+ if (existsSync(metaPath)) {
+ const metaRaw = await readFile(metaPath, 'utf-8');
+ const meta = safeJSONParse(metaRaw, {});
+ if (meta.enrichment?.questionsAnswered) {
+ const enrichmentSummary = Object.entries(meta.enrichment.questionsAnswered)
+ .filter(([, count]) => count > 0)
+ .map(([cat, count]) => `${cat}: ${count} answers`)
+ .join(', ');
+ if (enrichmentSummary) {
+ contextParts.push(`## Enrichment Progress\n${enrichmentSummary}`);
+ sourcesUsed.push('enrichment');
+ }
+ }
+ }
+
+ // Read existing taste responses from other completed sections
+ const profile = await loadTasteProfile();
+ for (const [sid, sectionData] of Object.entries(profile.sections)) {
+ if (sid === sectionId || !sectionData.responses?.length) continue;
+ const config = TASTE_SECTIONS[sid];
+ if (!config) continue;
+ const excerpt = sectionData.responses.slice(0, 3).map(r => {
+ const qDef = findQuestionDef(sid, r.questionId);
+ return `Q: ${qDef?.text || r.questionId}\nA: ${r.answer.slice(0, 300)}`;
+ }).join('\n\n');
+ if (excerpt) {
+ contextParts.push(`## Taste: ${config.label}\n${excerpt}`);
+ sourcesUsed.push(`taste:${sid}`);
+ }
+ }
+
+ if (contextParts.length === 0) return { context: '', sourcesUsed: [] };
+
+ // Truncate combined context to max length
+ let combined = contextParts.join('\n\n---\n\n');
+ if (combined.length > MAX_CONTEXT_CHARS) {
+ combined = combined.slice(0, MAX_CONTEXT_CHARS) + '\n\n[...truncated]';
+ }
+
+ return { context: combined, sourcesUsed };
+}
+
+/**
+ * Generate a personalized follow-up question for a taste section using LLM.
+ */
+export async function generatePersonalizedTasteQuestion(sectionId, providerId, model) {
+ const config = TASTE_SECTIONS[sectionId];
+ if (!config) return null;
+
+ const { context, sourcesUsed } = await aggregateIdentityContext(sectionId);
+ if (!context) return null;
+
+ const provider = providerId
+ ? await getProviderById(providerId)
+ : await getActiveProvider();
+
+ if (!provider) return null;
+
+ const modelId = model || provider.defaultModel;
+
+ // Build existing responses transcript
+ const profile = await loadTasteProfile();
+ const sectionData = profile.sections[sectionId] || { responses: [] };
+ const transcript = sectionData.responses.map(r => {
+ const qDef = findQuestionDef(sectionId, r.questionId);
+ return `Q: ${qDef?.text || r.questionId}\nA: ${r.answer}`;
+ }).join('\n\n');
+
+ const prompt = `You are a thoughtful interviewer building an aesthetic taste profile for someone. You already know a lot about this person from their identity documents and previous responses. Your job is to ask ONE follow-up question about "${config.label}" that:
+
+1. References something specific from their identity context (a book they read, music they like, a personality trait, a preference)
+2. Connects it to the ${config.label} domain in a surprising or insightful way
+3. Feels conversational and curious, not clinical or formulaic
+4. Goes deeper than generic taste questions — probe the "why" behind their preferences
+
+## Identity Context
+${context}
+
+## Previous ${config.label} Responses
+${transcript || '(No responses yet for this section)'}
+
+## Instructions
+Generate exactly ONE question. Do not include any preamble, numbering, or explanation. Just the question text itself. Keep it under 150 words. Make it feel like a question from someone who genuinely knows and is curious about this person.`;
+
+ const result = await callProviderAISimple(provider, modelId, prompt, { temperature: 0.8, max_tokens: 200 });
+
+ if (result.error || !result.text?.trim()) {
+ console.log(`🎨 Personalized question generation failed for ${sectionId}: ${result.error || 'empty response'}`);
+ return null;
+ }
+
+ const questionId = `${sectionId}-p25-${uuidv4()}`;
+ console.log(`🎨 Personalized question generated for ${sectionId} (${sourcesUsed.length} sources)`);
+
+ return {
+ questionId,
+ text: result.text.trim(),
+ isPersonalized: true,
+ identityContextUsed: sourcesUsed,
+ section: sectionId,
+ sectionLabel: config.label
+ };
+}
+
// =============================================================================
// HELPERS
// =============================================================================