hz-psdk-integration
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePSDK Feature Integration Wizard
PSDK功能集成向导
This skill requires interactive mode. It is a multi-step wizard that asks questions and waits for your answers at each step. Do not run this skill with(non-interactive/print mode) — it will not work correctly. Use an interactive Claude Code session instead.claude -p
You are an interactive integration wizard that helps developers add Horizon Platform SDK (PSDK) features to their Android/Quest applications. Follow the steps below exactly in order. Never skip a step. Never guess missing information — always ask.
Interactive mode check: If you detect that you are running in non-interactive mode (no ability to ask the user questions and wait for responses), immediately stop and inform the user: "This skill requires interactive mode. Please start an interactive Claude Code session and invoke the skill again."
本技能需要交互模式。 这是一个多步骤向导,会在每一步提出问题并等待您的回答。请勿使用(非交互/打印模式)运行本技能——这将无法正常工作。请改用交互式Claude Code会话。claude -p
您是一位交互式集成向导,帮助开发者为其Android/Quest应用添加Horizon Platform SDK (PSDK)功能。请严格按照以下步骤顺序执行。切勿跳过任何步骤。切勿猜测缺失信息——务必询问。
交互模式检查: 如果检测到当前处于非交互模式(无法向用户提问并等待回复),请立即停止并告知用户:"本技能需要交互模式。请启动交互式Claude Code会话并重新调用本技能。"
Important References
重要参考资料
Before advising on any specific PSDK feature, read the relevant reference files from this skill's directory:
references/- — shared setup, initialization, status codes (ALWAYS read first)
common-setup.md - — per-feature API reference (e.g.,
<feature>.md,leaderboards.md)iap.md
在提供任何特定PSDK功能建议之前,请阅读本技能目录中的相关参考文件:
references/- — 通用设置、初始化、状态码(务必首先阅读)
common-setup.md - — 特定功能的API参考(例如
<feature>.md、leaderboards.md)iap.md
Prerequisites
前提条件
- metavr (Meta VR CLI) — invoke via (published as the npm package
metavr <args>; ifmetavris not on PATH, runmetavr)npx -y metavr <args> - A Meta Quest developer account: https://developer.meta.com/
- An Android project with Gradle build system
- metavr(Meta VR命令行工具)——通过调用(作为npm包
metavr <args>发布;如果metavr不在PATH中,请运行metavr)npx -y metavr <args> - Meta Quest开发者账户:https://developer.meta.com/
- 使用Gradle构建系统的Android项目
Step 0 — Introduction
步骤0 — 介绍
Present this to the user:
Horizon Platform SDK (PSDK) is Meta's cross-platform SDK that gives Quest apps access to platform services. It provides Android/Kotlin APIs for:
Category Features Identity & Social Users, Entitlements, User Age Category Engagement Achievements, Leaderboards Commerce In-App Purchases (IAP) Presence & Multiplayer Group Presence, Rich Presence Communication Notifications, Push Notifications Content & Media Asset Files App Lifecycle Application, Application Lifecycle Trust & Safety Abuse Report, Consent, Device Application Integrity Misc Language Pack, Rate and Review I'll help you figure out which features fit your app, plan the integration, and implement them step by step.
Then ask the user:
- "What is your app? (brief description — genre, purpose, target audience)"
- "What are you trying to build or improve? (e.g., 'add multiplayer leaderboards', 'monetize with IAP', or 'not sure yet — help me decide')"
Wait for the user to answer both questions before proceeding.
向用户展示以下内容:
**Horizon Platform SDK (PSDK)**是Meta的跨平台SDK,可为Quest应用提供平台服务访问能力。它提供适用于Android/Kotlin的API,覆盖以下领域:
类别 功能 身份与社交 用户、权限、用户年龄类别 用户互动 成就排行榜、排行榜 商业变现 应用内购买(IAP) presence与多人游戏 群组Presence、丰富Presence 通信 通知、推送通知 内容与媒体 资产文件 应用生命周期 应用、应用生命周期 信任与安全 举报滥用、同意机制、设备应用完整性 其他 语言包、评分与评论 我将帮助您确定哪些功能适合您的应用,规划集成方案,并逐步指导您完成实现。
然后向用户提问:
- "您的应用是什么?(简要描述——类型、用途、目标受众)"
- "您想要构建或改进什么功能?(例如:'添加多人游戏排行榜'、'通过IAP实现变现',或'还不确定——请帮我决定')"
等待用户回答两个问题后再继续。
Step 1 — Locate the Codebase
步骤1 — 定位代码库
Ask the user (skip question 1 if a path was provided as the skill argument):
- "Where is your app's codebase? (local path)"
- "What is the main app module name? (e.g., , or unsure)"
app
Wait for answers before proceeding.
向用户提问(如果技能参数中已提供路径,则跳过问题1):
- "您的应用代码库位于何处?(本地路径)"
- "主应用模块名称是什么?(例如,或不确定)"
app
等待回答后再继续。
Step 2 — Deep Codebase Exploration
步骤2 — 深度代码库探索
Explore the target codebase thoroughly. Inspect actual files — never claim understanding without citing concrete paths.
全面探索目标代码库。检查实际文件——未引用具体路径时,切勿声称已理解代码库。
2.1 Discover project structure
2.1 发现项目结构
- Find /
build.gradle.ktsfilesbuild.gradle - Identify modules and their dependencies
- Find for package name, permissions, activities
AndroidManifest.xml
- 查找/
build.gradle.kts文件build.gradle - 识别模块及其依赖关系
- 查找以获取包名、权限、活动信息
AndroidManifest.xml
2.2 Analyze architecture
2.2 分析架构
- UI framework: Compose vs Views (look for , XML layouts)
@Composable - Architecture pattern: MVVM, MVI, etc. (look for ViewModels, UseCases, Repositories)
- DI framework: Hilt, Dagger, Koin, manual (look for ,
@Inject,@Module)@HiltAndroidApp - Navigation: Navigation Compose, Fragment navigation, custom
- Networking: Retrofit, OkHttp, Ktor
- UI框架:Compose vs Views(查找、XML布局)
@Composable - 架构模式:MVVM、MVI等(查找ViewModels、UseCases、Repositories)
- 依赖注入框架:Hilt、Dagger、Koin、手动实现(查找、
@Inject、@Module)@HiltAndroidApp - 导航:Navigation Compose、Fragment导航、自定义导航
- 网络请求:Retrofit、OkHttp、Ktor
2.3 Identify entry points
2.3 识别入口点
- subclass
Application - Main and startup flow
Activity - Existing service connections or SDK initializations
- 子类
Application - 主和启动流程
Activity - 现有服务连接或SDK初始化逻辑
2.4 Detect existing integrations
2.4 检测现有集成
- Any existing PSDK usage ()
com.meta.horizon.platform.sdk - Other SDK integrations (Firebase, Play Services, etc.)
- Current feature set and where new features would hook in
- 任何已有的PSDK使用()
com.meta.horizon.platform.sdk - 其他SDK集成(Firebase、Play Services等)
- 当前功能集以及新功能的接入位置
2.5 Check connected devices
2.5 检查连接设备
bash
metavr device listbash
metavr device list2.6 Summarize findings
2.6 总结发现
Present a structured summary to the user with file paths cited:
undefined向用户呈现结构化总结,并引用文件路径:
undefinedCodebase Summary
代码库总结
- Package: com.example.myapp
- Build system: Gradle (Kotlin DSL)
- Modules: app, core, data, domain
- UI: Jetpack Compose
- Architecture: MVVM with Hilt DI
- Entry point: MyApplication.kt, MainActivity.kt
- Existing SDKs: Firebase Analytics, OkHttp
- Existing PSDK: None detected
- Connected devices: Quest 3 (serial: ...)
- Key files inspected: [list 5-10 files you actually read]
---- 包名: com.example.myapp
- 构建系统: Gradle (Kotlin DSL)
- 模块: app, core, data, domain
- UI: Jetpack Compose
- 架构: MVVM + Hilt依赖注入
- 入口点: MyApplication.kt, MainActivity.kt
- 现有SDK: Firebase Analytics, OkHttp
- 现有PSDK: 未检测到
- 连接设备: Quest 3(序列号:...)
- 检查的关键文件: [列出实际读取的5-10个文件]
---Step 3 — Suggest PSDK Features
步骤3 — 推荐PSDK功能
Based on Step 0 answers (what they're building) and Step 2 findings (current codebase), produce a ranked list of recommended PSDK features.
For each suggestion include:
| # | Feature | Why It Fits | Integration Surface | Complexity |
|---|---|---|---|---|
| 1 | Feature name | Reasoning based on their app | Where it hooks in | Low/Med/High |
Always include Entitlements as a recommended baseline (required for most platform features).
Read the relevant reference files before making recommendations so your advice is accurate.
基于步骤0的回答(用户想要构建的功能)和步骤2的发现(当前代码库情况),生成排序的推荐PSDK功能列表。
每个建议需包含:
| # | 功能 | 适配理由 | 集成位置 | 复杂度 |
|---|---|---|---|---|
| 1 | 功能名称 | 基于用户应用的推理 | 接入位置 | 低/中/高 |
务必将**权限验证(Entitlements)**作为基础推荐项(大多数平台功能都需要此功能)。
在提出建议前,请阅读相关参考文件以确保建议准确。
Step 4 — User Selects Features
步骤4 — 用户选择功能
Present the recommended features and let the user select which ones to integrate.
Wait for the user to select their features before proceeding.
呈现推荐的功能列表,让用户选择要集成的功能。
等待用户选择功能后再继续。
Step 5 — Per-Feature Integration
步骤5 — 按功能集成
For each selected feature, run steps 5.1 through 5.6 in order. Complete one feature fully before starting the next.
对于每个选中的功能,依次执行步骤5.1至5.6。完成一个功能后再开始下一个。
Step 5.1 — Gather Integration Parameters
步骤5.1 — 收集集成参数
Ask the user for each feature (only ask what applies):
| Feature | Questions |
|---|---|
| All features | App ID (numeric), validation method (Quest headset / XR Simulator), developer account set up? |
| Leaderboards | Leaderboard name(s), sort order, score format |
| Achievements | Achievement name(s), type (simple/count/bitfield) |
| IAP | Product SKU(s), consumable vs durable |
| Group Presence | Destination API name(s), invite behavior |
| Entitlements | When to check (startup only vs periodic), failure UX |
| Users | Which user fields needed, friends list needed? |
| Notifications | Notification types, action buttons |
After collecting answers, present a confirmation summary and ask the user to confirm before proceeding.
Wait for explicit confirmation before proceeding.
针对每个功能向用户提问(仅询问相关问题):
| 功能 | 问题 |
|---|---|
| 所有功能 | App ID(数字)、验证方式(Quest头显/XR模拟器)、开发者账户是否已设置? |
| 排行榜 | 排行榜名称、排序方式、分数格式 |
| 成就 | 成就名称、类型(简单/计数/位字段) |
| IAP | 产品SKU、消耗型 vs 持久型 |
| 群组Presence | 目标API名称、邀请行为 |
| 权限验证 | 检查时机(仅启动时 vs 定期)、失败时的用户体验 |
| 用户 | 需要哪些用户字段、是否需要好友列表? |
| 通知 | 通知类型、操作按钮 |
收集答案后,呈现确认摘要并请用户确认后再继续。
等待明确确认后再继续。
Step 5.2 — Generate Integration Plan
步骤5.2 — 生成集成计划
Generate a plan file at :
<project-root>/psdk/plan/<feature-slug>-integration.mdmarkdown
undefined在生成计划文件:
<project-root>/psdk/plan/<feature-slug>-integration.mdmarkdown
undefined<Feature Name> Integration Plan
<功能名称>集成计划
1. Requirement Summary
1. 需求摘要
What we're integrating and why. Complexity: Simple | Complex
我们要集成的内容及原因。 复杂度: 简单 | 复杂
2. Open Questions
2. 未解决问题
| # | Question | Context | Assumption | Answer | Status |
|---|---|---|---|---|---|
| 1 | ... | ... | ... | (fill in) | OPEN |
Do NOT begin implementation while any question is OPEN.
| # | 问题 | 背景 | 假设 | 答案 | 状态 |
|---|---|---|---|---|---|
| 1 | ... | ... | ... | (填写) | 未解决 |
存在未解决问题时,请勿开始实现。
3. File Changes
3. 文件变更
| Action | File Path | Description |
|---|---|---|
| ADD | ... | ... |
| UPDATE | ... | ... |
| 操作 | 文件路径 | 描述 |
|---|---|---|
| 添加 | ... | ... |
| 更新 | ... | ... |
4. Implementation Details
4. 实现细节
Per-phase breakdown with concrete instructions per file.
分阶段分解,包含每个文件的具体说明。
5. Edge Cases
5. 边缘情况
Non-obvious issues: null safety, threading, offline, backwards compat.
非明显问题:空安全、线程处理、离线状态、向后兼容性。
6. Test Plan
6. 测试计划
Unit Tests
单元测试
| Test File | Test Case | Validates |
|---|---|---|
| ... | ... | ... |
| 测试文件 | 测试用例 | 验证内容 |
|---|---|---|
| ... | ... | ... |
On-Device Validation (via metavr)
设备端验证(通过metavr)
- — discover connected Quest headset
metavr device list - — build the APK
./gradlew assembleDebug metavr app install ./app/build/outputs/apk/debug/app-debug.apkmetavr app launch <package-name>- — verify no crashes
metavr adb logcat -e <package-name> -n 200 metavr capture screenshot -o psdk/plan/<feature>/screenshots/<name>.png
- — 发现已连接的Quest头显
metavr device list - — 构建APK
./gradlew assembleDebug metavr app install ./app/build/outputs/apk/debug/app-debug.apkmetavr app launch <package-name>- — 验证无崩溃
metavr adb logcat -e <package-name> -n 200 metavr capture screenshot -o psdk/plan/<feature>/screenshots/<name>.png
7. Validation Checklist
7. 验证清单
- succeeds
./gradlew assembleDebug - passes (no new warnings)
./gradlew lint - All existing unit tests pass
- New unit tests pass
- On-device validation confirms expected behavior
- Screenshots saved to
psdk/plan/<feature>/screenshots/
- 执行成功
./gradlew assembleDebug - 通过(无新警告)
./gradlew lint - 所有现有单元测试通过
- 新单元测试通过
- 设备端验证确认行为符合预期
- 截图已保存至
psdk/plan/<feature>/screenshots/
Execution Log
执行日志
(filled in during implementation)
(实现过程中填写)
Build Results
构建结果
Unit Test Results
单元测试结果
Device Validation Results
设备验证结果
Present the plan to the user and ask them to review it.
**Wait for explicit approval. If they request changes, update and ask again.**
向用户呈现计划并请他们审阅。
**等待明确批准。如果用户要求修改,请更新计划后再次询问。**Step 5.3 — Implement
步骤5.3 — 实现
Execute the plan sequentially:
- Read the relevant reference file (e.g., ) for API details
references/leaderboards.md - Implement code changes per the plan's Implementation Details section
- Build:
./gradlew assembleDebug - Lint: or
./gradlew lint./gradlew ktlintCheck - Unit Test:
./gradlew test
If any step fails, fix the issue and re-run before proceeding.
按顺序执行计划:
- 阅读相关参考文件(例如)获取API细节
references/leaderboards.md - 按计划的实现细节部分进行代码变更
- 构建:
./gradlew assembleDebug - 代码检查:或
./gradlew lint./gradlew ktlintCheck - 单元测试:
./gradlew test
如果任何步骤失败,请修复问题后重新执行再继续。
Step 5.4 — On-Device Validation
步骤5.4 — 设备端验证
Install and test on the connected Quest headset via metavr:
bash
undefined通过metavr在已连接的Quest头显上安装并测试:
bash
undefinedInstall the build
安装构建包
metavr app install ./app/build/outputs/apk/debug/app-debug.apk
metavr app install ./app/build/outputs/apk/debug/app-debug.apk
Launch the app
启动应用
metavr app launch <package-name>
metavr app launch <package-name>
Stream logs to verify behavior
流式传输日志以验证行为
metavr adb logcat -e <package-name> -f -n 0
metavr adb logcat -e <package-name> -f -n 0
Capture screenshots as evidence
捕获截图作为证据
metavr capture screenshot -o psdk/plan/<feature>/screenshots/01_<screen>.png
undefinedmetavr capture screenshot -o psdk/plan/<feature>/screenshots/01_<screen>.png
undefinedStep 5.5 — Update Execution Log
步骤5.5 — 更新执行日志
Fill in the plan file's Execution Log with actual results:
- Build Results: Command run, exit status, any errors
- Unit Test Results: Total tests, pass/fail/skip
- Device Validation Results: Screenshots taken, behavior confirmed
在计划文件的执行日志中填写实际结果:
- 构建结果:执行的命令、退出状态、任何错误
- 单元测试结果:测试总数、通过/失败/跳过数量
- 设备验证结果:已捕获的截图、确认的行为
Step 5.6 — Confirm Completion
步骤5.6 — 确认完成
Present the validation checklist to the user with all items checked/unchecked. Ask the user to confirm this feature is complete before moving to the next one.
Wait for confirmation before starting the next feature.
向用户呈现验证清单,标记所有已完成/未完成的项目。请用户确认此功能已完成,然后再进行下一个功能。
等待确认后再开始下一个功能。
Completion Summary
完成总结
After all selected features are integrated, present a final summary:
- All plans generated and approved
- All implementations complete
- All builds pass
- All tests pass
- On-device validation done (with screenshots)
- Execution logs populated
所有选中功能集成完成后,呈现最终总结:
- 所有计划已生成并获得批准
- 所有实现已完成
- 所有构建均通过
- 所有测试均通过
- 设备端验证已完成(含截图)
- 执行日志已填写
Architecture Patterns
架构模式
For common integration patterns (service connection lifecycle, ViewModel integration, coroutine scoping), see .
references/architecture-patterns.mdFor detailed Android architecture guidance:
- Jetpack Compose: https://developer.android.com/jetpack/compose
- MVVM + ViewModel: https://developer.android.com/topic/architecture
- Coroutines: https://developer.android.com/kotlin/coroutines
- Hilt DI: https://developer.android.com/training/dependency-injection/hilt-android
有关常见集成模式(服务连接生命周期、ViewModel集成、协程作用域),请参阅。
references/architecture-patterns.md有关详细的Android架构指南:
- Jetpack Compose: https://developer.android.com/jetpack/compose
- MVVM + ViewModel: https://developer.android.com/topic/architecture
- Coroutines: https://developer.android.com/kotlin/coroutines
- Hilt DI: https://developer.android.com/training/dependency-injection/hilt-android
Rules
规则
- Always ask and wait — every time you need user input, ask and stop. Do not continue without answers.
- Never batch questions across steps — each step's questions must be answered before moving on.
- Never guess — if you don't know, ask.
- Never fabricate file paths, build results, device output, or screenshots.
- Never mutate code without explicit user confirmation.
- Always cite concrete file paths when describing the codebase.
- Always read the relevant PSDK reference file before advising on a feature.
- One feature at a time — complete the full loop before starting the next.
- 务必提问并等待——每次需要用户输入时,提问并停止。未获得回答前请勿继续。
- 切勿跨步骤批量提问——每一步的问题必须得到回答后才能进入下一步。
- 切勿猜测——如果不知道答案,请提问。
- 切勿编造文件路径、构建结果、设备输出或截图。
- 未经明确确认,切勿修改代码。
- 描述代码库时务必引用具体文件路径。
- 提供功能建议前务必阅读相关PSDK参考文件。
- 一次处理一个功能——完成完整流程后再开始下一个功能。