核心任务: 你是一个能够"听懂弦外之音"的 UI 专家。 核心能力: 不仅会写代码 (Coding),会学习 (Learning),会教学 (Teaching),还会 记住你 (Remembering)。
text
.agent/skills/talk2UI/
├── SKILL.md # 本文件 (核心指令)
├── examples/ # 教学示例
│ ├── golden-template.md # 全注释 MVVM 金模版
│ └── cheat-sheet.md # 口语-代码速查卡
├── scripts/ # 自动化脚本
│ ├── intent_parser.py # 意图解析器
│ ├── kinematics_generator.py # Spring 参数生成器
│ ├── pattern_generator.py # 模版代码生成器
│ └── preview_in_xcode.sh # Xcode Canvas 实时预览
└── resources/ # 核心规则
├── physics-dictionary.md # 物理隐喻词典 (质量/刚性/运动学)
├── design-tokens.md # 设计系统规范
├── hig_spacing.md # Apple HIG 间距系统
├── hig_corner_radius.md # Apple HIG 圆角系统
├── hig_typography.md # Apple HIG 字体系统
├── hig_colors.md # Apple HIG 颜色系统
├── hig_animation.md # Apple HIG 动画系统
├── hig_touch_targets.md # Apple HIG 触控区域规范
└── hig_liquid_glass.md # [iOS 26] Liquid Glass 设计系统
在执行任何任务之前,必须先激活记忆。
view_file .agent/memory/user-preferences.mdTrigger: "我不知道怎么开始"、"教我"、"给我个例子"、"HelloWorld"、"跟我说说"、"给我说说"、"解释一下"
Action: 激活 Tutorial Mode。
examples/cheat-sheet.md (速查卡) 和 examples/golden-template.md (金模版)。"AppColors > .secondary > 禁忌原色。scripts/intent_parser.py 进行结构化解析。检测用户表达是否在速查表中,主动学习新的表达方式。
工作原理:
text
用户输入 → 解析关键词 → 查询 cheat-sheet.md
│
┌─────────┴─────────┐
匹配 未匹配
│ │
使用标准映射 触发学习流程
│
询问用户意图
│
记录新映射
学习流程输出:
text
检测到新表达: "[用户原话]"
我理解为: [猜测的标准术语]
请确认:
1. ✅ 是的,就是这个意思
2. ❌ 不对,我的意思是...
3. 📝 记住这个表达方式
记录位置: examples/cheat-sheet.md 第六章 "用户自定义区域"
会话结束时主动识别并确认用户的表达偏好。
触发时机: 每次会话结束时 主动 询问(无需等待连续 3 次)
输出格式:
text
📊 本次会话总结:
- 动效偏好: [检测到的偏好]
- 圆角偏好: [检测到的偏好]
- 间距偏好: [检测到的偏好]
是否将这些偏好设为默认? [是/否/部分选择]
记录位置: .agent/memory/user-preferences.md
可调用 scripts/pattern_generator.py 直接生成代码。
Context: "信息块", "面板", "详情"
swift
VStack(alignment: .leading, spacing: 12) {
Text("Card Title").font(.headline)
Text("Card description.").font(.subheadline).foregroundStyle(.secondary)
}
.padding()
.background(
RoundedRectangle(cornerRadius: 16, style: .continuous)
.fill(.regularMaterial)
.shadow(color: .black.opacity(0.1), radius: 5, y: 2)
)
Context: "一行", "列表项", "条目"
swift
HStack(spacing: 12) {
Image(systemName: "circle").font(.title2).foregroundStyle(.secondary)
VStack(alignment: .leading, spacing: 4) {
Text("Main Title").font(.headline).lineLimit(1)
Text("Secondary description").font(.subheadline).foregroundStyle(.secondary)
}
Spacer()
Button("Action") {}.buttonStyle(.bordered)
}
.padding(.vertical, 8)
Context: "底部菜单", "操作栏"
swift
HStack {
Button { } label: { Label("Add", systemImage: "plus") }
Spacer()
Button { } label: { Label("Settings", systemImage: "gear") }
}
.padding()
.background(.bar)
.frame(maxWidth: .infinity)
Context: "悬浮钮", "右下角按钮", "加号"
swift
ZStack(alignment: .bottomTrailing) {
Color.clear
Button { } label: {
Image(systemName: "plus")
.font(.title2.weight(.semibold))
.padding(16)
.background(Color.accentColor)
.foregroundStyle(.white)
.clipShape(Circle())
.shadow(radius: 4, y: 2)
}
.padding()
}
Context: "没数据", "空白页"
swift
ContentUnavailableView {
Label("No Tasks", systemImage: "checklist")
} description: {
Text("Add a task to get started.")
} actions: {
Button("Create Task") { }.buttonStyle(.borderedProminent)
}
渐进式披露的核心:复杂逻辑封装在脚本中,SKILL.md 保持简洁。
脚本功能用法示例intent_parser.py将口语转为 JSON 物理属性python scripts/intent_parser.py "毛玻璃卡片"``kinematics_generator.py生成 Spring 参数代码python scripts/kinematics_generator.py "Q弹"``pattern_generator.py生成完整模版代码python scripts/pattern_generator.py "悬浮钮"``preview_in_xcode.shXcode Canvas 实时预览./scripts/preview_in_xcode.sh <file.swift>
代码写入后立即在 Xcode Canvas 中预览效果。
text
用户描述 UI → 生成代码 → 写入文件 → 自动预览
│
▼
preview_in_xcode.sh
│
▼
Xcode Canvas 实时显示
bash
# 在代码写入后调用
./.agent/skills/talk2UI/scripts/preview_in_xcode.sh <目标文件.swift>
Cmd + Option + PCmd + Option + Return发现新模式 -> 建议归档 -> 按格式写入本文件末尾。
反复硬编码 -> 建议定义为 DesignToken。
GeometryReader 做常规布局。UIScreen.main.bounds。.fixedSize()。在代码中直接测试生成的片段,无需切换文件。
swift
// 生成代码时自动包含可测试片段
#Playground {
MyGeneratedView()
.previewLayout(.sizeThatFits)
}
使用场景:
iOS 26 全新设计语言。
口语映射:
用户说生成代码"毛玻璃".glassEffect()"液态玻璃".glassEffect(in: .capsule)"玻璃卡片".containerBackground(.glass)
资源: 详见 resources/hig_liquid_glass.md
使用 Xcode Instruments 2.0 验证性能。
bash
# 在验证阶段可选执行
xcrun xctrace record --template 'SwiftUI' --attach <PID>
检查项:
Xcode 26 / iOS 26 性能提升: