Add host-first environment contracts (Local vs CI vs Prod), deps-only compose, and the Profile → Portrait → deep-access mock payment slice with device identity and auto-migrate on API startup. Co-authored-by: Cursor <cursoragent@cursor.com>
147 lines
5.7 KiB
Go
147 lines
5.7 KiB
Go
// Package portrait builds deterministic personal-portrait content from birth date.
|
|
// Copy follows .ai/product/lexicon.md — exploration / analysis, not fortune-telling.
|
|
package portrait
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
// Output is free summary + gated detail for a GrowthReport.
|
|
type Output struct {
|
|
Summary map[string]any `json:"summary"`
|
|
Detail map[string]any `json:"detail"`
|
|
}
|
|
|
|
// Build generates 个人画像 content from a birth date (deterministic).
|
|
func Build(birth time.Time, displayName string) Output {
|
|
y, m, d := birth.Date()
|
|
num := reduce(y) + reduce(int(m)) + reduce(d)
|
|
for num > 9 {
|
|
num = reduce(num)
|
|
}
|
|
trait := traits[num%len(traits)]
|
|
name := displayName
|
|
if name == "" {
|
|
name = "你"
|
|
}
|
|
|
|
summary := map[string]any{
|
|
"title": "基础画像",
|
|
"headline": fmt.Sprintf("%s更偏「%s」的互动风格", name, trait.Label),
|
|
"keywords": trait.Keywords,
|
|
"one_liner": trait.OneLiner,
|
|
"life_tip": trait.LifeTip,
|
|
"pattern_key": num,
|
|
}
|
|
detail := map[string]any{
|
|
"title": "完整分析",
|
|
"behavior_pattern": trait.Behavior,
|
|
"relation_style": trait.Relation,
|
|
"growth_direction": trait.Growth,
|
|
"daily_suggestions": []string{
|
|
trait.LifeTip,
|
|
"遇到分歧时,先复述对方观点再表达自己的需要。",
|
|
"用一周记录情绪与精力高峰,找到更适合自己的节奏。",
|
|
},
|
|
}
|
|
return Output{Summary: summary, Detail: detail}
|
|
}
|
|
|
|
type trait struct {
|
|
Label string
|
|
Keywords []string
|
|
OneLiner string
|
|
LifeTip string
|
|
Behavior string
|
|
Relation string
|
|
Growth string
|
|
}
|
|
|
|
var traits = []trait{
|
|
{
|
|
Label: "稳健探索", Keywords: []string{"条理", "耐心", "观察"},
|
|
OneLiner: "你习惯先理解再行动,适合把复杂事情拆成小步。",
|
|
LifeTip: "今天给自己一段不被打断的专注时间。",
|
|
Behavior: "决策偏审慎,信息充分时执行力更强;压力下可能拖延。",
|
|
Relation: "更愿意用行动表达关心,需要对方给予明确反馈。",
|
|
Growth: "练习在信息不完整时做小步试验,积累行动信心。",
|
|
},
|
|
{
|
|
Label: "热情连接", Keywords: []string{"表达", "共鸣", "主动"},
|
|
OneLiner: "你容易带动气氛,也需要被真诚回应。",
|
|
LifeTip: "把想说的话写下来,再选择合适的时机分享。",
|
|
Behavior: "行动快、反馈敏感;情绪起伏会影响专注时长。",
|
|
Relation: "重视即时沟通,冷处理容易让你感到不安。",
|
|
Growth: "学会区分「被回应」与「被认同」,减少过度解读。",
|
|
},
|
|
{
|
|
Label: "理性澄清", Keywords: []string{"分析", "边界", "清晰"},
|
|
OneLiner: "你擅长把模糊感受变成可讨论的问题。",
|
|
LifeTip: "睡前做一次简短复盘:今天最有价值的一件事是什么。",
|
|
Behavior: "偏好逻辑框架;在情绪场域可能显得抽离。",
|
|
Relation: "沟通时需要结构和具体例子,忌空泛安慰。",
|
|
Growth: "在分析之外,练习先接纳情绪再谈方案。",
|
|
},
|
|
{
|
|
Label: "柔韧调节", Keywords: []string{"适应", "体察", "平衡"},
|
|
OneLiner: "你善于照顾氛围,也别忘了照顾自己的节奏。",
|
|
LifeTip: "安排一次轻度活动,帮助身心回到平稳状态。",
|
|
Behavior: "弹性强,容易迁就;长期可能积压需求。",
|
|
Relation: "更在意关系和谐,冲突时倾向先安抚场面。",
|
|
Growth: "练习用「我需要…」表达边界,而不是只做协调者。",
|
|
},
|
|
{
|
|
Label: "目标推进", Keywords: []string{"决断", "效率", "成果"},
|
|
OneLiner: "你推动事情落地的能力突出,记得留白给休息。",
|
|
LifeTip: "把今日目标收束到一件最重要的事。",
|
|
Behavior: "结果导向,节奏偏快;对低效协作耐心有限。",
|
|
Relation: "欣赏直接沟通的人,含糊表态会消耗信任。",
|
|
Growth: "把「效率」与「关系维护」列为同等优先级的周目标。",
|
|
},
|
|
{
|
|
Label: "内观沉淀", Keywords: []string{"深度", "独立", "洞察"},
|
|
OneLiner: "你习惯向内理解世界,适合深度思考类任务。",
|
|
LifeTip: "留出安静独处时间,整理近期的想法与感受。",
|
|
Behavior: "思考深入,对外表达可能滞后于内心结论。",
|
|
Relation: "需要安全感和节奏感,突然施压会让你退回内在。",
|
|
Growth: "把洞察翻译成可分享的语言,让重要的人跟上你。",
|
|
},
|
|
{
|
|
Label: "创意发散", Keywords: []string{"想象", "灵感", "可能"},
|
|
OneLiner: "你容易看到多种可能性,适合用原型验证想法。",
|
|
LifeTip: "用纸笔画出今天最想尝试的一个小实验。",
|
|
Behavior: "点子多、切换快;收尾与复盘是短板。",
|
|
Relation: "喜欢有趣的对话,重复与僵化会让你疏离。",
|
|
Growth: "为每个灵感设定「最小完成定义」,提高闭环率。",
|
|
},
|
|
{
|
|
Label: "责任担当", Keywords: []string{"可靠", "承诺", "稳定"},
|
|
OneLiner: "你重视承诺与秩序,是团队里让人安心的存在。",
|
|
LifeTip: "检查一下是否把别人的期待误当成自己的必须。",
|
|
Behavior: "可靠且自律;过度负责时容易耗竭。",
|
|
Relation: "用持续在场表达在乎,需要被看见付出。",
|
|
Growth: "练习委托与求助,让支持系统真正运转起来。",
|
|
},
|
|
{
|
|
Label: "敏锐觉察", Keywords: []string{"细腻", "直觉", "体贴"},
|
|
OneLiner: "你对情绪与细节敏感,适合需要同理的场景。",
|
|
LifeTip: "觉察身体信号:紧张时先放慢呼吸再回应。",
|
|
Behavior: "感知力强;信息过载时容易内耗。",
|
|
Relation: "能很快读到对方状态,也易被情绪感染。",
|
|
Growth: "建立「感受—事实—选择」三步,减少被情绪牵着走。",
|
|
},
|
|
}
|
|
|
|
func reduce(n int) int {
|
|
if n < 0 {
|
|
n = -n
|
|
}
|
|
sum := 0
|
|
for n > 0 {
|
|
sum += n % 10
|
|
n /= 10
|
|
}
|
|
return sum
|
|
}
|