@sokeai/cli 1.0.65 → 1.0.67

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/README.md +35 -0
  2. package/package.json +1 -1
  3. package/scripts/build-binaries.sh +10 -1
  4. package/skills/README.md +2 -0
  5. package/skills/SKILL.md +33 -1
  6. package/skills/ai-coach-director/.learnings/LEARNINGS.md +71 -0
  7. package/skills/ai-coach-director/SKILL.md +1229 -0
  8. package/skills/ai-coach-director/assets/ERRORS-TEMPLATE.md +5 -0
  9. package/skills/ai-coach-director/assets/FEATURE_REQUESTS-TEMPLATE.md +5 -0
  10. package/skills/ai-coach-director/assets/LEARNINGS-TEMPLATE.md +45 -0
  11. package/skills/ai-coach-director/assets/SKILL-TEMPLATE.md +177 -0
  12. package/skills/ai-coach-director/coaching/prompt-engineer/parts/part1-basic.md +59 -0
  13. package/skills/ai-coach-director/coaching/prompt-engineer/parts/part2-roles.md +317 -0
  14. package/skills/ai-coach-director/coaching/prompt-engineer/parts/part3-flow.md +72 -0
  15. package/skills/ai-coach-director/coaching/prompt-engineer/parts/part4-scoring.md +87 -0
  16. package/skills/ai-coach-director/coaching/prompt-engineer/parts/part5-constraints.md +48 -0
  17. package/skills/ai-coach-director/coaching/prompt-engineer/prompt-engineer.md +217 -0
  18. package/skills/ai-coach-director/coaching/prompt-optimizer/prompt-optimizer.md +362 -0
  19. package/skills/ai-coach-director/coaching/role-profiler/role-profiler.md +87 -0
  20. package/skills/ai-coach-director/platform/interaction.md +312 -0
  21. package/skills/ai-coach-director/platform/soke-ai-training/soke-ai-training.md +93 -0
  22. package/skills/ai-coach-director/platform/sync-engine.md +974 -0
  23. package/skills/ai-coach-director/references/cases/AI/345/256/242/346/210/267/350/247/222/350/211/262/346/250/241/346/235/277/345/272/223.md +265 -0
  24. package/skills/ai-coach-director/references/cases/AI/351/231/252/347/273/203Bad Case/346/240/267/346/234/254/345/272/223.md" +206 -0
  25. package/skills/ai-coach-director/references/cases/AI/351/231/252/347/273/203/345/210/233/345/273/272/351/227/256/351/242/230/345/272/223.md +666 -0
  26. package/skills/ai-coach-director/references/cases/AI/351/231/252/347/273/203/345/234/272/346/231/257/345/210/206/347/261/273/345/272/223.md +213 -0
  27. package/skills/ai-coach-director/references/cases/AI/351/231/252/347/273/203/345/256/242/346/210/267/346/235/220/346/226/231/346/270/205/345/215/225/344/270/216/350/256/277/350/260/210/351/242/230/345/272/223.md +229 -0
  28. package/skills/ai-coach-director/references/cases/AI/351/231/252/347/273/203/345/276/256/350/260/203/351/227/256/351/242/230/345/272/223.md +833 -0
  29. package/skills/ai-coach-director/references/cases/AI/351/231/252/347/273/203/346/212/200/346/234/257/350/276/271/347/225/214/344/270/216/346/216/222/351/232/234/345/272/223.md +239 -0
  30. package/skills/ai-coach-director/references/cases/AI/351/231/252/347/273/203/346/217/220/347/244/272/350/257/215/346/250/241/345/235/227/345/272/223.md +249 -0
  31. package/skills/ai-coach-director/references/cases/AI/351/231/252/347/273/203/346/225/260/346/215/256/346/214/207/346/240/207/344/270/216/347/234/213/346/235/277/345/217/243/345/276/204/345/272/223.md +282 -0
  32. package/skills/ai-coach-director/references/cases/AI/351/231/252/347/273/203/346/265/213/350/257/225/347/224/250/344/276/213/345/272/223.md +254 -0
  33. package/skills/ai-coach-director/references/cases/AI/351/231/252/347/273/203/350/257/204/345/210/206/346/240/207/345/207/206/347/273/204/344/273/266/345/272/223.md +264 -0
  34. package/skills/ai-coach-director/references/cases/AI/351/231/252/347/273/203/351/241/271/347/233/256/346/241/210/344/276/213/345/244/215/347/233/230/345/272/223.md +223 -0
  35. package/skills/ai-coach-director/references/cases/AI/351/241/276/345/256/242/350/247/222/350/211/262/346/250/241/346/213/237_GoodCase_BadCase_20260701.md +304 -0
  36. package/skills/ai-coach-director/references/cases/create//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277/347/224/265/350/257/235/347/272/246/350/256/277//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277/345/256/242/346/210/267/346/235/220/346/226/231/346/261/207/346/200/273_2026-05-19_1341.md +42 -0
  37. package/skills/ai-coach-director/references/cases/create//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277/347/224/265/350/257/235/347/272/246/350/256/277//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277/347/224/265/350/257/235/347/272/246/350/256/277_/346/240/207/345/207/206/347/237/245/350/257/206/345/272/223.md +199 -0
  38. package/skills/ai-coach-director/references/cases/create//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277/347/224/265/350/257/235/347/272/246/350/256/277//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277/347/224/265/350/257/235/347/272/246/350/256/277/347/237/245/350/257/206/345/272/223.md +388 -0
  39. package/skills/ai-coach-director/references/cases/create//346/226/260/350/203/275/346/272/220/350/275/246/344/270/273/350/264/267//346/226/260/350/203/275/346/272/220/350/275/246/344/270/273/350/264/267/347/237/245/350/257/206/345/272/223/347/224/237/346/210/220_20260615.md +23 -0
  40. package/skills/ai-coach-director/references/cases/create//346/226/260/350/203/275/346/272/220/350/275/246/344/270/273/350/264/267//346/226/260/350/203/275/346/272/220/350/275/246/344/270/273/350/264/267/351/231/252/347/273/203/346/217/220/347/244/272/350/257/215/347/224/237/346/210/220_20260615.md +34 -0
  41. package/skills/ai-coach-director/references/cases/create//346/237/220/345/233/275/351/231/205/346/243/200/346/265/213/346/234/272/346/236/204/tuv-knowledge-base.md +125 -0
  42. package/skills/ai-coach-director/references/cases/create//346/237/220/345/233/275/351/231/205/346/243/200/346/265/213/346/234/272/346/236/204/tuv-p03-first-call-scenario-prompt.md +428 -0
  43. package/skills/ai-coach-director/references/cases/create//346/237/220/345/233/275/351/231/205/346/243/200/346/265/213/346/234/272/346/236/204//346/237/220/345/233/275/351/231/205/346/243/200/346/265/213/346/234/272/346/236/204P03/351/231/252/347/273/203/346/211/247/350/241/214/346/226/271/346/241/210_20260610.md +225 -0
  44. package/skills/ai-coach-director/references/cases/create//346/237/220/345/233/275/351/231/205/346/243/200/346/265/213/346/234/272/346/236/204//346/237/220/345/233/275/351/231/205/346/243/200/346/265/213/346/234/272/346/236/204/351/231/252/347/273/203/346/211/247/350/241/214/346/226/271/346/241/210/344/272/244/344/273/230/350/256/260/345/275/225_20260610.md +26 -0
  45. package/skills/ai-coach-director/references/cases/create//346/237/220/345/234/260/346/226/271/351/223/266/350/241/214//346/237/220/345/234/260/346/226/271/351/223/266/350/241/214/345/206/234/346/210/267/345/274/240/350/200/201/346/235/277/347/224/265/350/257/235/347/272/246/350/256/277AI/351/231/252/347/273/203/346/265/213/350/257/225/347/224/250/344/276/213/345/220/210/351/233/206.md +525 -0
  46. package/skills/ai-coach-director/references/cases/create//347/211/251/346/265/201/350/241/214/344/270/232//347/211/251/346/265/201/350/241/214/344/270/232-/345/210/235/346/254/241/346/213/234/350/256/277/351/246/231/347/262/276/351/246/231/346/226/231/345/256/242/346/210/267.md +146 -0
  47. package/skills/ai-coach-director/references/cases/create//351/205/222/345/272/227/351/244/220/351/245/256//351/205/222/345/272/227/351/244/220/351/245/256AI/351/231/252/347/273/203_/346/240/207/346/235/2061_/346/226/260/345/223/201/346/216/250/351/224/200_20260701.md +230 -0
  48. package/skills/ai-coach-director/references/cases/create//351/205/222/345/272/227/351/244/220/351/245/256//351/205/222/345/272/227/351/244/220/351/245/256AI/351/231/252/347/273/203_/346/240/207/346/235/2062_/345/202/254/350/217/234/345/256/211/346/212/232_20260701.md +257 -0
  49. package/skills/ai-coach-director/references/cases/create//351/205/222/345/272/227/351/244/220/351/245/256//351/205/222/345/272/227/351/244/220/351/245/256AI/351/231/252/347/273/203_/346/240/207/346/235/2063_/345/267/256/350/257/204/345/233/236/350/256/277_20260701.md +259 -0
  50. package/skills/ai-coach-director/references/cases/create//351/205/222/345/272/227/351/244/220/351/245/256//351/205/222/345/272/227/351/244/220/351/245/256AI/351/231/252/347/273/203/345/234/272/346/231/257/346/226/271/346/241/210_20260701.md +452 -0
  51. package/skills/ai-coach-director/references/cases/create//351/231/214/346/213/234/344/277/241/346/201/257/346/224/266/351/233/206//351/231/214/346/213/234/344/277/241/346/201/257/346/224/266/351/233/206_/345/256/242/346/210/267/347/241/256/350/256/244/345/217/215/351/246/210/350/241/250.md +133 -0
  52. package/skills/ai-coach-director/references/cases/create//351/231/214/346/213/234/344/277/241/346/201/257/346/224/266/351/233/206//351/231/214/346/213/234/344/277/241/346/201/257/346/224/266/351/233/206_/346/217/220/347/244/272/350/257/215/346/220/255/345/273/272_20260622.md +30 -0
  53. package/skills/ai-coach-director/references/cases/create//351/231/214/346/213/234/344/277/241/346/201/257/346/224/266/351/233/206//351/231/214/346/213/234/344/277/241/346/201/257/346/224/266/351/233/206_/351/231/252/347/273/203/346/217/220/347/244/272/350/257/215_v1.md +333 -0
  54. package/skills/ai-coach-director/references/cases/create//351/231/214/346/213/234/344/277/241/346/201/257/346/224/266/351/233/206//351/231/214/346/213/234/344/277/241/346/201/257/346/224/266/351/233/206_/351/231/252/347/273/203/346/217/220/347/244/272/350/257/215_v2_Part1-Part5.md +649 -0
  55. package/skills/ai-coach-director/references/cases/micro-tune//344/274/201/344/270/232/345/256/266/347/216/213/346/200/273/347/263/273/345/210/227//344/274/201/344/270/232/345/256/266/347/216/213/346/200/273/346/217/220/347/244/272/350/257/215_/344/274/230/345/214/226/347/211/210_V1.1_20260616.md +262 -0
  56. package/skills/ai-coach-director/references/cases/micro-tune//344/274/201/344/270/232/345/256/266/347/216/213/346/200/273/347/263/273/345/210/227//344/274/201/344/270/232/345/256/266/347/216/213/346/200/273/346/217/220/347/244/272/350/257/215_/344/274/230/345/214/226/347/211/210_V1.2_20260616.md +254 -0
  57. package/skills/ai-coach-director/references/cases/micro-tune//344/274/201/344/270/232/345/256/266/347/216/213/346/200/273/347/263/273/345/210/227//344/274/201/344/270/232/345/256/266/347/216/213/346/200/273/346/217/220/347/244/272/350/257/215_/345/216/213/347/274/251/347/211/210_V2.0_20260616.md +96 -0
  58. package/skills/ai-coach-director/references/cases/micro-tune//344/274/201/344/270/232/345/256/266/347/216/213/346/200/273/347/263/273/345/210/227//344/274/201/344/270/232/345/256/266/347/216/213/346/200/273/346/217/220/347/244/272/350/257/215/344/274/230/345/214/226_20260616.md +20 -0
  59. package/skills/ai-coach-director/references/cases/micro-tune//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277/347/263/273/345/210/227//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277AI/351/231/252/347/273/203/347/263/273/347/273/237_/346/265/213/350/257/225/345/217/215/351/246/210/346/261/207/346/200/273_2026-06-01.md +434 -0
  60. package/skills/ai-coach-director/references/cases/micro-tune//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277/347/263/273/345/210/227//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277KYC/344/277/241/344/273/273/345/200/274/347/246/201/344/273/244_2026-06-09_0932.md +22 -0
  61. package/skills/ai-coach-director/references/cases/micro-tune//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277/347/263/273/345/210/227//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277KYC/346/217/220/347/244/272/350/257/215_/344/274/230/345/214/226/347/211/210_v2_20260608.md +261 -0
  62. package/skills/ai-coach-director/references/cases/micro-tune//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277/347/263/273/345/210/227//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277/346/217/220/347/244/272/350/257/215_/344/274/230/345/214/226/347/211/210_v1.1.md +277 -0
  63. package/skills/ai-coach-director/references/cases/micro-tune//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277/347/263/273/345/210/227//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277/346/217/220/347/244/272/350/257/215_/344/274/230/345/214/226/347/211/210_v1.2.md +354 -0
  64. package/skills/ai-coach-director/references/cases/micro-tune//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277/347/263/273/345/210/227//345/206/234/346/210/267/345/274/240/350/200/201/346/235/277/346/217/220/347/244/272/350/257/215/344/274/230/345/214/226_V2_/350/257/212/346/226/255/344/272/244/344/273/230_20260609.md +26 -0
  65. package/skills/ai-coach-director/references/cases//345/233/233/345/244/247/345/234/272/346/231/257_GoodCase_BadCase_20260701.md +194 -0
  66. package/skills/ai-coach-director/references/cases//346/241/210/344/276/213/345/272/223/350/241/245/345/205/205_2026-06-24.md +41 -0
  67. package/skills/ai-coach-director/references/change-log-partwise-refactor.md +74 -0
  68. package/skills/ai-coach-director/references/env-check.md +132 -0
  69. package/skills/ai-coach-director/references/platform-api-pitfalls.md +218 -0
  70. package/skills/ai-coach-director/references/role-resource-matching.md +312 -0
  71. package/skills/ai-coach-director/references/self-improvement-examples.md +374 -0
  72. package/skills/ai-coach-director/references/verified-cli-cheatsheet.md +189 -0
  73. package/skills/ai-coach-director/scripts/activator.sh +4 -0
  74. package/skills/ai-coach-director/scripts/error-detector.sh +4 -0
  75. package/skills/ai-coach-director/scripts/extract-skill.sh +7 -0
  76. package/skills/soke-ai-training/SKILL.md +22 -1
  77. package/skills/soke-cli/345/256/211/350/243/205/346/214/207/345/215/227.md +3 -3
  78. package/skills/soke-course/SKILL.md +1 -1
  79. package/skills/soke-course/soke-cli/345/256/211/350/243/205/346/214/207/345/215/227.md +3 -3
  80. package/skills/soke-exam/SKILL.md +1 -1
  81. package/skills/soke-examPool/SKILL.md +124 -0
  82. package/skills/soke-learning-map/SKILL.md +1 -1
  83. package/skills/soke-learning-map/soke-cli/345/256/211/350/243/205/346/214/207/345/215/227.md +3 -3
  84. package/skills/soke-learning-profile/SKILL.md +1 -1
  85. package/skills/soke-photo-gallery/SKILL.md +1 -1
  86. package/skills/soke-shared/SKILL.md +1 -0
  87. package/skills/soke-training-demand/SKILL.md +112 -0
@@ -0,0 +1,312 @@
1
+ # Part2 平台资源自动匹配规则
2
+
3
+ > 本节是 Part2 角色创建后自动执行的资源匹配流程。头像和语音不在 Part2 内容生成阶段预设,而是在角色落地后查询系统资源库自动匹配。
4
+ >
5
+ > **v2.0 升级**:匹配模式从"拉全量→文本匹配"升级为"提取角色性别/年龄特征→CLI 参数精准过滤→取结果",利用 CLI 原生的 `--gender` / `--age-group` 服务端过滤能力,提升匹配精度和效率。
6
+
7
+ ## 资源匹配时机
8
+
9
+ Part2 `replace_ai_roles` / `add_ai_role` apply 成功 → 立即执行资源匹配流程,不等待用户触发。
10
+
11
+ ---
12
+
13
+ ## 前置步骤:从角色卡提取性别与年龄
14
+
15
+ 在执行任何 CLI 查询之前,必须先从每个角色的 `role_data` 中提取性别和年龄段特征,映射为 CLI 参数:
16
+
17
+ ### 性别映射表(gender)
18
+
19
+ | 角色描述中的特征词 | → gender |
20
+ |---|---|
21
+ | 男、先生、他、男士、男性、(男性名字:建国/振国/志强/伟等) | `male` |
22
+ | 女、女士、她、太太、小姐、女性、(女性名字:芳/丽/敏/娟/婷等) | `female` |
23
+ | 无明显性别特征 | 不传 `--gender` |
24
+
25
+ > **提取优先级**:角色名称(.name) > 角色描述(.description) > 角色背景(.background) > MBTI+沟通风格交叉推断
26
+
27
+ ### 年龄段映射表(age_group)
28
+
29
+ | 角色描述中的特征词 | → age_group |
30
+ |---|---|
31
+ | 青年、年轻、刚毕业、新手、25-35、初级、新入职、小张/小李等年轻称呼 | `youth` |
32
+ | 中年、35-50、资深、经理、主管、部门负责人、有多年经验 | `middle-aged` |
33
+ | 老年、50+、退休、资深专家、老前辈、临近退休、老张/老李等长辈称呼 | `senior` |
34
+ | 无明显年龄特征 | 不传 `--age-group` |
35
+
36
+ > **提取优先级**:角色背景(.background) > 角色描述(.description) > 角色名称(.name)
37
+
38
+ ---
39
+
40
+ ## 头像资源匹配
41
+
42
+ ### Step 1:CLI 精准过滤查询
43
+
44
+ 根据前置步骤提取的 `gender` 和 `age_group`,使用 CLI 过滤参数查询:
45
+
46
+ ```bash
47
+ # 性别+年龄都明确 → 一阶精准查询
48
+ soke-cli ai-training +list-role-avatars \
49
+ --gender <gender> \
50
+ --age-group <age_group> \
51
+ --lang zh \
52
+ --show-detail \
53
+ --pretty
54
+
55
+ # 仅性别明确 → 仅按性别过滤
56
+ soke-cli ai-training +list-role-avatars \
57
+ --gender <gender> \
58
+ --lang zh \
59
+ --show-detail \
60
+ --pretty
61
+
62
+ # 特征信息不足 → 不传过滤参数
63
+ soke-cli ai-training +list-role-avatars \
64
+ --lang zh \
65
+ --show-detail \
66
+ --pretty
67
+ ```
68
+
69
+ ### Step 2:从过滤结果中选最佳匹配
70
+
71
+ CLI 返回的头像列表已经是服务端按 `sort` 排序的过滤结果。按以下优先级选取:
72
+
73
+ | 优先级 | 匹配条件 | 选取规则 |
74
+ |---|---|---|
75
+ | P0 | 性别 + 年龄都吻合 | 取过滤结果中 `sort` 最小的第 1 条 |
76
+ | P1 | 仅性别吻合(年龄无精确匹配) | 取 `--gender` 过滤结果的第 1 条 |
77
+ | P2 | 仅年龄吻合(性别无精确匹配) | 取 `--age-group` 过滤结果的第 1 条 |
78
+ | P3 | 性别年龄均无匹配 | 不传过滤参数,全量取第 1 条通用/中性头像,并标注「无精确匹配」 |
79
+
80
+ > **降级链路**:一阶查询返回空 → 去掉 `--age-group`(仅性别)→ 仍空则去掉 `--gender`(仅年龄)→ 仍空则全量无过滤。每次降级记录一次。
81
+
82
+ ### Step 3:写入角色
83
+
84
+ > ⚠️ **必须与语音资源合并写入**:头像和语音写入**同一个** `patch_ai_role` 操作,不可分两次。合并写入示例见文件末尾「合并写入模板」。
85
+
86
+ 使用 `patch_ai_role` 将匹配到的头像资源 URL 写入(与 voice_id 合并为单次操作):
87
+
88
+ ```json
89
+ [
90
+ {
91
+ "type": "patch_ai_role",
92
+ "data": {
93
+ "scenario_role_id": "<角色ID>",
94
+ "patch": {
95
+ "role_data": {
96
+ "avatar": "<头像资源URL>"
97
+ },
98
+ "customized_fields": ["avatar"]
99
+ }
100
+ }
101
+ }
102
+ ]
103
+ ```
104
+
105
+ > ⚠️ `avatar` 字段传入头像资源 **URL**(如 `https://newsokeeditorcdn.soke.cn/public/ai/avatars/business_owner_female.png`),来自 `+list-role-avatars` 返回的 `url` 字段,**不能**传资源 `id`。
106
+ > ⚠️ `patch` 中必须包含 `customized_fields`,指明被修改的字段,否则平台可能不识别该更新。
107
+
108
+ 匹配结果在聊天中只显示一行摘要(如「张总 → 威严中年男性头像」),不展示原始 JSON。
109
+
110
+ ---
111
+
112
+ ## 语音资源匹配
113
+
114
+ ### Step 1:CLI 精准过滤查询
115
+
116
+ ```bash
117
+ # 性别+年龄都明确 → 一阶精准查询
118
+ soke-cli ai-training +list-role-voices \
119
+ --gender <gender> \
120
+ --age-group <age_group> \
121
+ --lang zh \
122
+ --pretty
123
+
124
+ # 降级查询(同头像降级链路)
125
+ ```
126
+
127
+ ### Step 2:从过滤结果中选最佳匹配
128
+
129
+ | 优先级 | 匹配条件 | 选取规则 |
130
+ |---|---|---|
131
+ | P0 | 性别 + 年龄都吻合 | 取过滤结果的第 1 条 |
132
+ | P1 | 仅性别吻合 | 取 `--gender` 过滤结果的第 1 条 |
133
+ | P2 | 仅年龄吻合 | 取 `--age-group` 过滤结果的第 1 条 |
134
+ | P3 | 性别年龄均无匹配 | 全量取第 1 条通用默认音色,标注「无精确匹配」 |
135
+
136
+ > **降级链路**:同头像匹配——一阶→去年龄→去性别→全量。每次降级记录一次。
137
+
138
+ ### Step 3:写入角色
139
+
140
+ > ⚠️ **必须与头像资源合并写入**:语音和头像写入**同一个** `patch_ai_role` 操作,不可分两次。合并写入示例见文件末尾「合并写入模板」。
141
+
142
+ 使用 `patch_ai_role` 将匹配到的语音资源 ID 写入(与 avatar 合并为单次操作):
143
+
144
+ ```json
145
+ [
146
+ {
147
+ "type": "patch_ai_role",
148
+ "data": {
149
+ "scenario_role_id": "<角色ID>",
150
+ "patch": {
151
+ "role_data": {
152
+ "voice_id": "<语音资源ID>"
153
+ },
154
+ "customized_fields": ["voice_id"]
155
+ }
156
+ }
157
+ }
158
+ ]
159
+ ```
160
+
161
+ > ⚠️ `voice_id` 传入声音资源 **ID**(如 `zh_female_warm_01`),来自 `+list-role-voices` 返回的 `id` 字段,**不能**传 `sample_url` 或名称字符串。
162
+ > ⚠️ `patch` 中必须包含 `customized_fields`,指明被修改的字段。
163
+
164
+ 匹配结果在聊天中只显示一行摘要(如「张总 → 沉稳中年男声」)。
165
+
166
+ ---
167
+
168
+ ## 完整流程时序
169
+
170
+ ```
171
+ Part2 角色 apply 成功
172
+ → 提取角色性别(gender) + 年龄(age_group)
173
+ → CLI 并行精准过滤查询:
174
+ +list-role-avatars --gender <g> --age-group <a> --lang zh --show-detail --pretty
175
+ +list-role-voices --gender <g> --age-group <a> --lang zh --pretty
176
+ → 任一返回空则降级(去年龄→去性别→全量)
177
+ → ⚠️ 单次 patch_ai_role 合并写入 avatar + voice_id(customized_fields: ["avatar", "voice_id"])
178
+ → ⚠️ get-scenario 强制验证 avatar 非空 URL + voice_id 非空 ID
179
+ → 验证失败 → 重新读取 updated_at → 重试 1 次
180
+ → 仍失败 → 标注「资源匹配未完成」,不阻断后续 Part
181
+ → 资源匹配完成后,再进入 Part3
182
+ ```
183
+
184
+ > **头像/语音的 patch 操作用同一个 idempotency_key**(如 `cli-<scenario_short>-part2-resources`),avatar 和 voice_id 放在同一个 `patch_ai_role` 的 `patch.role_data` 中,`customized_fields` 写 `["avatar", "voice_id"]`。**禁止分两次 patch**——分开调用会导致 updated_at 竞态。
185
+
186
+ ---
187
+
188
+ ## 端到端示例
189
+
190
+ 角色卡摘要:
191
+ - 名称:谨慎型小微企业主
192
+ - 描述:经营农资批发门店的女性老板,40多岁,关注融资成本和审批速度。
193
+ - 背景:经营农资批发门店十余年,旺季前需短期周转资金 30-50 万……
194
+
195
+ ### 特征提取
196
+
197
+ | 特征 | 来源字段 | 提取结果 | CLI 参数 |
198
+ |---|---|---|---|
199
+ | 性别 | 描述中"女性" | female | `--gender female` |
200
+ | 年龄 | 描述中"40多岁"、背景中"十余年" | middle-aged | `--age-group middle-aged` |
201
+
202
+ ### CLI 查询
203
+
204
+ ```bash
205
+ # 头像
206
+ soke-cli ai-training +list-role-avatars \
207
+ --gender female \
208
+ --age-group middle-aged \
209
+ --lang zh \
210
+ --show-detail \
211
+ --pretty
212
+
213
+ # 声音
214
+ soke-cli ai-training +list-role-voices \
215
+ --gender female \
216
+ --age-group middle-aged \
217
+ --lang zh \
218
+ --pretty
219
+ ```
220
+
221
+ ### 写入
222
+
223
+ ```json
224
+ {
225
+ "role_data": {
226
+ "avatar": "https://newsokeeditorcdn.soke.cn/public/ai/avatars/business_owner_female.png",
227
+ "voice_id": "zh_female_warm_01"
228
+ }
229
+ }
230
+ ```
231
+
232
+ ---
233
+
234
+ ## 异常处理
235
+
236
+ | 情况 | 处理 |
237
+ |---|---|
238
+ | 头像/语音库 CLI 查询失败(网络/权限) | 跳过资源匹配,标注「资源匹配未完成」,Part3 不受影响 |
239
+ | 角色特征信息不足(无性别/年龄暗示) | 不传过滤参数,全量查询取第 1 条默认头像 + 默认音色,不标注匹配摘要 |
240
+ | 过滤查询返回空 → 降级后仍空 | 全量查询取第 1 条,标注「无精确匹配,已使用默认资源」 |
241
+ | patch_ai_role 失败 | 重新读取 updated_at 后重试 1 次;仍失败则标注,不阻断 Part3 |
242
+ | patch_ai_role 返回成功但 avatar/voice_id 验证为空 | 重新读取 updated_at 后重试 1 次;仍失败则标注,不阻断 Part3 |
243
+
244
+ ---
245
+
246
+ ## 合并写入模板
247
+
248
+ > ⚠️ **强制规则**:头像和语音必须合并为**单次** `patch_ai_role` 操作写入。禁止分两次 patch——分两次调用会导致第二次 patch 后 `updated_at` 变化,后续验收时可能误判第一次写入丢失。
249
+
250
+ ### operations JSON 结构
251
+
252
+ ```json
253
+ [
254
+ {
255
+ "type": "patch_ai_role",
256
+ "data": {
257
+ "scenario_role_id": "<角色ID>",
258
+ "patch": {
259
+ "role_data": {
260
+ "avatar": "<头像资源URL>",
261
+ "voice_id": "<语音资源ID>"
262
+ },
263
+ "customized_fields": ["avatar", "voice_id"]
264
+ }
265
+ }
266
+ }
267
+ ]
268
+ ```
269
+
270
+ ### 完整 CLI 命令序列
271
+
272
+ ```bash
273
+ # 1. 读取最新场景状态
274
+ soke-cli ai-training +get-scenario \
275
+ --scenario-id <scenario_id> \
276
+ --pretty
277
+
278
+ # 2. 写入合并的 operations JSON(Python json.dump)
279
+
280
+ # 3. 预览
281
+ soke-cli ai-training +preview-scenario-update \
282
+ --scenario-id <scenario_id> \
283
+ --base-updated-at <updated_at> \
284
+ --operations-file ./part2-resources.json \
285
+ --reason "Part2: 头像声音资源回填" \
286
+ --pretty
287
+
288
+ # 4. 应用
289
+ soke-cli ai-training +apply-scenario-update \
290
+ --scenario-id <scenario_id> \
291
+ --base-updated-at <updated_at> \
292
+ --operations-file ./part2-resources.json \
293
+ --idempotency-key "cli-<scenario_short>-part2-resources" \
294
+ --reason "Part2: 头像声音资源回填" \
295
+ --pretty
296
+
297
+ # 5. 强制验证
298
+ soke-cli ai-training +get-scenario \
299
+ --scenario-id <scenario_id> \
300
+ --pretty
301
+ # 检查每个角色的 avatar 为非空 URL、voice_id 为非空 ID
302
+ ```
303
+
304
+ ### 验证失败重试
305
+
306
+ ```bash
307
+ # 验证失败 → 重新读取 updated_at
308
+ soke-cli ai-training +get-scenario --scenario-id <scenario_id> --pretty
309
+
310
+ # 重新生成 patch → 重新 preview + apply(新 idempotency_key)
311
+ # 仍失败 → 标注并继续 Part3
312
+ ```
@@ -0,0 +1,374 @@
1
+ # Entry Examples
2
+
3
+ Concrete examples of well-formatted entries with all fields.
4
+
5
+ ## Learning: Correction
6
+
7
+ ```markdown
8
+ ## [LRN-20250115-001] correction
9
+
10
+ **Logged**: 2025-01-15T10:30:00Z
11
+ **Priority**: high
12
+ **Status**: pending
13
+ **Area**: tests
14
+
15
+ ### Summary
16
+ Incorrectly assumed pytest fixtures are scoped to function by default
17
+
18
+ ### Details
19
+ When writing test fixtures, I assumed all fixtures were function-scoped.
20
+ User corrected that while function scope is the default, the codebase
21
+ convention uses module-scoped fixtures for database connections to
22
+ improve test performance.
23
+
24
+ ### Suggested Action
25
+ When creating fixtures that involve expensive setup (DB, network),
26
+ check existing fixtures for scope patterns before defaulting to function scope.
27
+
28
+ ### Metadata
29
+ - Source: user_feedback
30
+ - Related Files: tests/conftest.py
31
+ - Tags: pytest, testing, fixtures
32
+
33
+ ---
34
+ ```
35
+
36
+ ## Learning: Knowledge Gap (Resolved)
37
+
38
+ ```markdown
39
+ ## [LRN-20250115-002] knowledge_gap
40
+
41
+ **Logged**: 2025-01-15T14:22:00Z
42
+ **Priority**: medium
43
+ **Status**: resolved
44
+ **Area**: config
45
+
46
+ ### Summary
47
+ Project uses pnpm not npm for package management
48
+
49
+ ### Details
50
+ Attempted to run `npm install` but project uses pnpm workspaces.
51
+ Lock file is `pnpm-lock.yaml`, not `package-lock.json`.
52
+
53
+ ### Suggested Action
54
+ Check for `pnpm-lock.yaml` or `pnpm-workspace.yaml` before assuming npm.
55
+ Use `pnpm install` for this project.
56
+
57
+ ### Metadata
58
+ - Source: error
59
+ - Related Files: pnpm-lock.yaml, pnpm-workspace.yaml
60
+ - Tags: package-manager, pnpm, setup
61
+
62
+ ### Resolution
63
+ - **Resolved**: 2025-01-15T14:30:00Z
64
+ - **Commit/PR**: N/A - knowledge update
65
+ - **Notes**: Added to CLAUDE.md for future reference
66
+
67
+ ---
68
+ ```
69
+
70
+ ## Learning: Promoted to CLAUDE.md
71
+
72
+ ```markdown
73
+ ## [LRN-20250115-003] best_practice
74
+
75
+ **Logged**: 2025-01-15T16:00:00Z
76
+ **Priority**: high
77
+ **Status**: promoted
78
+ **Promoted**: CLAUDE.md
79
+ **Area**: backend
80
+
81
+ ### Summary
82
+ API responses must include correlation ID from request headers
83
+
84
+ ### Details
85
+ All API responses should echo back the X-Correlation-ID header from
86
+ the request. This is required for distributed tracing. Responses
87
+ without this header break the observability pipeline.
88
+
89
+ ### Suggested Action
90
+ Always include correlation ID passthrough in API handlers.
91
+
92
+ ### Metadata
93
+ - Source: user_feedback
94
+ - Related Files: src/middleware/correlation.ts
95
+ - Tags: api, observability, tracing
96
+
97
+ ---
98
+ ```
99
+
100
+ ## Learning: Promoted to AGENTS.md
101
+
102
+ ```markdown
103
+ ## [LRN-20250116-001] best_practice
104
+
105
+ **Logged**: 2025-01-16T09:00:00Z
106
+ **Priority**: high
107
+ **Status**: promoted
108
+ **Promoted**: AGENTS.md
109
+ **Area**: backend
110
+
111
+ ### Summary
112
+ Must regenerate API client after OpenAPI spec changes
113
+
114
+ ### Details
115
+ When modifying API endpoints, the TypeScript client must be regenerated.
116
+ Forgetting this causes type mismatches that only appear at runtime.
117
+ The generate script also runs validation.
118
+
119
+ ### Suggested Action
120
+ Add to agent workflow: after any API changes, run `pnpm run generate:api`.
121
+
122
+ ### Metadata
123
+ - Source: error
124
+ - Related Files: openapi.yaml, src/client/api.ts
125
+ - Tags: api, codegen, typescript
126
+
127
+ ---
128
+ ```
129
+
130
+ ## Error Entry
131
+
132
+ ```markdown
133
+ ## [ERR-20250115-A3F] docker_build
134
+
135
+ **Logged**: 2025-01-15T09:15:00Z
136
+ **Priority**: high
137
+ **Status**: pending
138
+ **Area**: infra
139
+
140
+ ### Summary
141
+ Docker build fails on M1 Mac due to platform mismatch
142
+
143
+ ### Error
144
+ ```
145
+ error: failed to solve: python:3.11-slim: no match for platform linux/arm64
146
+ ```
147
+
148
+ ### Context
149
+ - Command: `docker build -t myapp .`
150
+ - Dockerfile uses `FROM python:3.11-slim`
151
+ - Running on Apple Silicon (M1/M2)
152
+
153
+ ### Suggested Fix
154
+ Add platform flag: `docker build --platform linux/amd64 -t myapp .`
155
+ Or update Dockerfile: `FROM --platform=linux/amd64 python:3.11-slim`
156
+
157
+ ### Metadata
158
+ - Reproducible: yes
159
+ - Related Files: Dockerfile
160
+
161
+ ---
162
+ ```
163
+
164
+ ## Error Entry: Recurring Issue
165
+
166
+ ```markdown
167
+ ## [ERR-20250120-B2C] api_timeout
168
+
169
+ **Logged**: 2025-01-20T11:30:00Z
170
+ **Priority**: critical
171
+ **Status**: pending
172
+ **Area**: backend
173
+
174
+ ### Summary
175
+ Third-party payment API timeout during checkout
176
+
177
+ ### Error
178
+ ```
179
+ TimeoutError: Request to payments.example.com timed out after 30000ms
180
+ ```
181
+
182
+ ### Context
183
+ - Command: POST /api/checkout
184
+ - Timeout set to 30s
185
+ - Occurs during peak hours (lunch, evening)
186
+
187
+ ### Suggested Fix
188
+ Implement retry with exponential backoff. Consider circuit breaker pattern.
189
+
190
+ ### Metadata
191
+ - Reproducible: yes (during peak hours)
192
+ - Related Files: src/services/payment.ts
193
+ - See Also: ERR-20250115-X1Y, ERR-20250118-Z3W
194
+
195
+ ---
196
+ ```
197
+
198
+ ## Feature Request
199
+
200
+ ```markdown
201
+ ## [FEAT-20250115-001] export_to_csv
202
+
203
+ **Logged**: 2025-01-15T16:45:00Z
204
+ **Priority**: medium
205
+ **Status**: pending
206
+ **Area**: backend
207
+
208
+ ### Requested Capability
209
+ Export analysis results to CSV format
210
+
211
+ ### User Context
212
+ User runs weekly reports and needs to share results with non-technical
213
+ stakeholders in Excel. Currently copies output manually.
214
+
215
+ ### Complexity Estimate
216
+ simple
217
+
218
+ ### Suggested Implementation
219
+ Add `--output csv` flag to the analyze command. Use standard csv module.
220
+ Could extend existing `--output json` pattern.
221
+
222
+ ### Metadata
223
+ - Frequency: recurring
224
+ - Related Features: analyze command, json output
225
+
226
+ ---
227
+ ```
228
+
229
+ ## Feature Request: Resolved
230
+
231
+ ```markdown
232
+ ## [FEAT-20250110-002] dark_mode
233
+
234
+ **Logged**: 2025-01-10T14:00:00Z
235
+ **Priority**: low
236
+ **Status**: resolved
237
+ **Area**: frontend
238
+
239
+ ### Requested Capability
240
+ Dark mode support for the dashboard
241
+
242
+ ### User Context
243
+ User works late hours and finds the bright interface straining.
244
+ Several other users have mentioned this informally.
245
+
246
+ ### Complexity Estimate
247
+ medium
248
+
249
+ ### Suggested Implementation
250
+ Use CSS variables for colors. Add toggle in user settings.
251
+ Consider system preference detection.
252
+
253
+ ### Metadata
254
+ - Frequency: recurring
255
+ - Related Features: user settings, theme system
256
+
257
+ ### Resolution
258
+ - **Resolved**: 2025-01-18T16:00:00Z
259
+ - **Commit/PR**: #142
260
+ - **Notes**: Implemented with system preference detection and manual toggle
261
+
262
+ ---
263
+ ```
264
+
265
+ ## Learning: Promoted to Skill
266
+
267
+ ```markdown
268
+ ## [LRN-20250118-001] best_practice
269
+
270
+ **Logged**: 2025-01-18T11:00:00Z
271
+ **Priority**: high
272
+ **Status**: promoted_to_skill
273
+ **Skill-Path**: skills/docker-m1-fixes
274
+ **Area**: infra
275
+
276
+ ### Summary
277
+ Docker build fails on Apple Silicon due to platform mismatch
278
+
279
+ ### Details
280
+ When building Docker images on M1/M2 Macs, the build fails because
281
+ the base image doesn't have an ARM64 variant. This is a common issue
282
+ that affects many developers.
283
+
284
+ ### Suggested Action
285
+ Add `--platform linux/amd64` to docker build command, or use
286
+ `FROM --platform=linux/amd64` in Dockerfile.
287
+
288
+ ### Metadata
289
+ - Source: error
290
+ - Related Files: Dockerfile
291
+ - Tags: docker, arm64, m1, apple-silicon
292
+ - See Also: ERR-20250115-A3F, ERR-20250117-B2D
293
+
294
+ ---
295
+ ```
296
+
297
+ ## Extracted Skill Example
298
+
299
+ When the above learning is extracted as a skill, it becomes:
300
+
301
+ **File**: `skills/docker-m1-fixes/SKILL.md`
302
+
303
+ ```markdown
304
+ ---
305
+ name: docker-m1-fixes
306
+ description: "Fixes Docker build failures on Apple Silicon (M1/M2). Use when docker build fails with platform mismatch errors."
307
+ ---
308
+
309
+ # Docker M1 Fixes
310
+
311
+ Solutions for Docker build issues on Apple Silicon Macs.
312
+
313
+ ## Quick Reference
314
+
315
+ | Error | Fix |
316
+ |-------|-----|
317
+ | `no match for platform linux/arm64` | Add `--platform linux/amd64` to build |
318
+ | Image runs but crashes | Use emulation or find ARM-compatible base |
319
+
320
+ ## The Problem
321
+
322
+ Many Docker base images don't have ARM64 variants. When building on
323
+ Apple Silicon (M1/M2/M3), Docker attempts to pull ARM64 images by
324
+ default, causing platform mismatch errors.
325
+
326
+ ## Solutions
327
+
328
+ ### Option 1: Build Flag (Recommended)
329
+
330
+ Add platform flag to your build command:
331
+
332
+ \`\`\`bash
333
+ docker build --platform linux/amd64 -t myapp .
334
+ \`\`\`
335
+
336
+ ### Option 2: Dockerfile Modification
337
+
338
+ Specify platform in the FROM instruction:
339
+
340
+ \`\`\`dockerfile
341
+ FROM --platform=linux/amd64 python:3.11-slim
342
+ \`\`\`
343
+
344
+ ### Option 3: Docker Compose
345
+
346
+ Add platform to your service:
347
+
348
+ \`\`\`yaml
349
+ services:
350
+ app:
351
+ platform: linux/amd64
352
+ build: .
353
+ \`\`\`
354
+
355
+ ## Trade-offs
356
+
357
+ | Approach | Pros | Cons |
358
+ |----------|------|------|
359
+ | Build flag | No file changes | Must remember flag |
360
+ | Dockerfile | Explicit, versioned | Affects all builds |
361
+ | Compose | Convenient for dev | Requires compose |
362
+
363
+ ## Performance Note
364
+
365
+ Running AMD64 images on ARM64 uses Rosetta 2 emulation. This works
366
+ for development but may be slower. For production, find ARM-native
367
+ alternatives when possible.
368
+
369
+ ## Source
370
+
371
+ - Learning ID: LRN-20250118-001
372
+ - Category: best_practice
373
+ - Extraction Date: 2025-01-18
374
+ ```