Expand guided reflection with CBT thought record and distortion routing
Adds a 5-step negative-mood reflection flow with an evidence-examination step, Socratic templated questions that back-reference prior answers, and a deterministic cognitive-distortion detector that routes the perspective- check prompt to a distortion-specific reframe. Includes CBT plan docs, flowchart, stats research notes, and MCP config. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -115,12 +115,38 @@ class FoundationModelsReflectionService {
|
||||
}
|
||||
.joined(separator: "\n\n")
|
||||
|
||||
// Intensity shift — if captured, tells the AI how much the reflection helped.
|
||||
var intensityLine = ""
|
||||
if let pre = reflection.preIntensity, let post = reflection.postIntensity {
|
||||
let delta = post - pre
|
||||
let direction: String
|
||||
if delta < 0 {
|
||||
direction = "dropped by \(abs(delta))"
|
||||
} else if delta > 0 {
|
||||
direction = "rose by \(delta)"
|
||||
} else {
|
||||
direction = "stayed the same"
|
||||
}
|
||||
intensityLine = "\nEmotional intensity: \(pre)/10 before → \(post)/10 after (\(direction)).\n"
|
||||
} else if let pre = reflection.preIntensity {
|
||||
intensityLine = "\nStarting emotional intensity: \(pre)/10.\n"
|
||||
}
|
||||
|
||||
// Detected cognitive distortion — if present, helps the AI speak to the specific
|
||||
// pattern the user worked through (e.g., "you caught yourself overgeneralizing").
|
||||
var distortionLine = ""
|
||||
if let distortion = reflection.detectedDistortion, distortion != .unknown {
|
||||
distortionLine = "\nDetected cognitive distortion in their automatic thought: \(distortion.rawValue). " +
|
||||
"Reference this pattern naturally in your observation without being clinical.\n"
|
||||
}
|
||||
|
||||
return """
|
||||
The user logged their mood as "\(moodName)" and completed a \(technique) reflection:
|
||||
|
||||
\(intensityLine)\(distortionLine)
|
||||
\(qaPairs)
|
||||
|
||||
Respond with personalized feedback that references their specific answers.
|
||||
Respond with personalized feedback that references their specific answers\
|
||||
\(reflection.preIntensity != nil && reflection.postIntensity != nil ? " and acknowledges the shift in how they're feeling" : "").
|
||||
"""
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user