argent-react-native-app-workflow
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinese1. Starting the React Native App
1. 启动React Native应用
1.1 Explore Configuration (MANDATORY — Do This First)
1.1 查看配置(必须执行——先做这一步)
Before running commands, read the project's build and run configuration from the subagent result.
argent-environment-inspectorDo NOT default to or without first checking for custom scripts and workflows.
npx react-native startnpx react-native run-iosManual fallback (if neither the agent nor the tool is available): read ALL scripts — look for custom scripts like , , , , flavors, etc. Custom scripts take priority over default commands. Also check for non-default port or watchFolders. For iOS builds, prefer opening over (CocoaPods generates the workspace).
package.jsonstart:localstart:deviosbuild:iosmetro.config.js.xcworkspace.xcodeprojIf the project structure is convoluted, ask the user before proceeding.
Remember the workflow: Once you discover the project's build/run workflow, save it to project memory so you don't need to re-discover it each time.
Checklist before start:
- present (if not:
node_modulesornpm install)yarn - For iOS: exists; if
ios/Podfilemissing or stale, runios/Podscd ios && pod install && cd .. - No conflicting Metro on default port (see 1.2)
在执行命令前,从子代理结果中读取项目的构建和运行配置。
argent-environment-inspector不要直接默认使用或,务必先检查是否存在自定义脚本和工作流。
npx react-native startnpx react-native run-ios手动备选方案(若代理或工具均不可用):阅读所有脚本——查找类似、、、、flavors等自定义脚本。自定义脚本优先级高于默认命令。同时检查是否有非默认端口或watchFolders配置。对于iOS构建,优先打开而非(CocoaPods会生成workspace)。
package.jsonstart:localstart:deviosbuild:iosmetro.config.js.xcworkspace.xcodeproj若项目结构复杂,在继续操作前请询问用户。
牢记工作流: 一旦确定项目的构建/运行工作流,将其保存到项目记忆中,避免每次重复查找。
启动前检查清单:
- 已存在(若不存在:执行
node_modules或npm install)yarn - 针对iOS:已存在;若
ios/Podfile缺失或过期,执行ios/Podscd ios && pod install && cd .. - 默认端口无冲突的Metro进程(见1.2)
1.2 Start Metro
1.2 启动Metro
-
Check whether metro is already running on port found in configuration and if it is - do not start another server. Refer to point 2.1.
-
Use the project's custom start script if one exists (e.g.,
npm run start:local). Fall back to default commands if no custom scripts are defined:yarn start:devbashnpx react-native startOptional:if cache issues are suspected.npx react-native start --reset-cache -
Verify Metro is ready: use thetool to verify Metro is running and reachable.
debugger-status -
Projects with flavors or custom configs: Use project-specific start script if present (e.g.), and start Metro before running the app.
npm run start:local
-
检查配置中指定的端口是否已有Metro在运行,若已运行则无需启动新服务器。参考2.1部分。
-
若项目存在自定义启动脚本,请优先使用(例如、
npm run start:local)。若无自定义脚本,再使用默认命令:yarn start:devbashnpx react-native start可选:若怀疑存在缓存问题,执行。npx react-native start --reset-cache -
验证Metro是否就绪:使用工具验证Metro是否正在运行且可访问。
debugger-status -
带有flavors或自定义配置的项目:若存在项目专属启动脚本(如),请使用该脚本,并在运行应用之前启动Metro。
npm run start:local
1.3 Run the App
1.3 运行应用
In a separate terminal (Metro keeps running in the first):
Use the project's custom build/run script if one exists (e.g. , , ). Only fall back to the defaults below if no custom scripts are defined.
npm run iosnpm run androidyarn ios:debugPass the target device explicitly — derive it from (see ):
list-devices<device_selection_rule>bash
npx react-native run-ios --simulator="<name>" # iOS (or --udid <UDID>)
npx react-native run-android --deviceId=<adb-serial> # AndroidAndroid only: after install, run so the emulator/device can reach Metro on your host. Repeat if the device restarts or adb drops.
adb -s <serial> reverse tcp:8081 tcp:8081Agent checklist:
- Metro is already running and shows "ready"
- Command run from project root
- If the device isn't booted yet: use with the iOS
boot-deviceor Androidudid. Refer to theavdName/argent-ios-simulator-setupskill.argent-android-emulator-setup - Android: done.
adb -s <serial> reverse tcp:8081 tcp:8081
在单独的终端中执行(Metro保持在第一个终端运行):
若项目存在自定义构建/运行脚本,请优先使用(例如、、)。仅当无自定义脚本时,才使用以下默认命令。
npm run iosnpm run androidyarn ios:debug明确指定目标设备——从结果中获取(参考):
list-devices<device_selection_rule>bash
npx react-native run-ios --simulator="<name>" # iOS(或使用--udid <UDID>)
npx react-native run-android --deviceId=<adb-serial> # Android仅Android: 安装完成后,执行,让模拟器/设备可以访问主机上的Metro。若设备重启或adb连接中断,请重复执行该命令。
adb -s <serial> reverse tcp:8081 tcp:8081代理检查清单:
- Metro已运行并显示"ready"
- 命令从项目根目录执行
- 若设备未启动:使用工具,传入iOS的
boot-device或Android的udid。参考avdName/argent-ios-simulator-setup技能。argent-android-emulator-setup - Android:已执行。
adb -s <serial> reverse tcp:8081 tcp:8081
2. Ensuring / Debugging Metro
2. 确保Metro正常运行/调试Metro
2.1 Check for Existing Metro
2.1 检查是否存在已运行的Metro
Before starting Metro, avoid "port already in use" errors. Default port to check is :8081, infer the port from documentation:
bash
lsof -i :PORT- No output → Port free; safe to start Metro.
- Output with PID → Another process is using the port.
Use the tool to check whether the process on that port is actually a Metro server. If not Metro — ask the user whether you may kill the process.
debugger-statusTo kill a Metro process, use the tool (requires user confirmation).
stop-metro启动Metro前,避免出现"端口已被占用"错误。默认检查端口为:8081,也可从文档中推断端口:
bash
lsof -i :PORT- 无输出 → 端口空闲;可安全启动Metro。
- 输出包含PID → 该端口已被其他进程占用。
使用工具检查该端口上的进程是否确实是Metro服务器。若不是Metro——询问用户是否可以终止该进程。
debugger-status要终止Metro进程,使用工具(需用户确认)。
stop-metro2.2 Confirm Correct Server Connection
2.2 确认服务器连接正确
- App must point at the same host/port as the running Metro. Default: same machine, port 8081.
- iOS Simulator: By default uses localhost; no extra config needed for same-machine Metro.
Verify Metro is reachable: use the tool.
debugger-status- 应用必须指向与运行中的Metro相同的主机/端口。默认:同一机器,端口8081。
- iOS模拟器: 默认使用localhost;同一机器上的Metro无需额外配置。
验证Metro是否可访问: 使用工具。
debugger-status2.3 Reload the App (Ensure New Bundle)
2.3 重新加载应用(确保加载新Bundle)
After code or config changes, the app must load the new bundle:
| Method | How |
|---|---|
| Reload tool | Use the |
| Restart app | Use the |
Agent checklist:
- Only one Metro process (no duplicate on port)
- App was started after Metro was ready
- When needing to reload: refer to 2.3
代码或配置更改后,应用必须加载新的bundle:
| 方法 | 操作方式 |
|---|---|
| 重载工具 | 使用 |
| 重启应用 | 使用 |
代理检查清单:
- 仅存在一个Metro进程(端口无重复进程)
- 应用在Metro就绪后启动
- 需要重载时:参考2.3部分
3. Build / Install / Retry (React Native & iOS Native)
3. 构建/安装/重试(React Native & iOS原生)
3.1 When Build Fails (e.g. xcodebuild exit code 65)
3.1 构建失败时(例如xcodebuild退出码65)
Order of operations (simplest first):
- Clean build folder, then retry the build command
- Clear caches and reinstall dependencies: reset Metro cache, , remove
watchman watch-del-all+ lockfile,node_modules, thennpm installcd ios && rm -rf build Pods Podfile.lock && pod install --repo-update - CocoaPods issues: then
pod deintegratepod install --repo-update - Open in Xcode for detailed errors in the Report navigator
ios/*.xcworkspace
操作顺序(从最简单的开始):
- 清理构建文件夹,然后重试构建命令
- 清除缓存并重新安装依赖:重置Metro缓存,执行,删除
watchman watch-del-all+ 锁文件,执行node_modules,然后执行npm installcd ios && rm -rf build Pods Podfile.lock && pod install --repo-update - CocoaPods问题:执行,然后执行
pod deintegratepod install --repo-update - 在Xcode中打开,在Report导航器中查看详细错误信息
ios/*.xcworkspace
3.2 When to Ask the User
3.2 何时询问用户
After 2-3 failed build or run attempts, STOP and ask the user for guidance. The user may know about required env vars, Xcode version requirements, custom build configurations, monorepo-specific setup, or required external services.
If the project structure is convoluted and the correct build approach is not obvious, ask the user early rather than guessing.
经过2-3次构建或运行尝试失败后,请停止操作并向用户寻求指导。 用户可能了解所需的环境变量、Xcode版本要求、自定义构建配置、monorepo专属设置或所需的外部服务。
若项目结构复杂且正确的构建方式不明确,请尽早询问用户,而非猜测。
3.3 Saving Build Workflow for Later
3.3 保存构建工作流供后续使用
Once you discover the correct build/run workflow for a project, save it to project memory. Capture: commands to start Metro, commands to build/run the app, and any required environment setup.
一旦确定项目正确的构建/运行工作流,请将其保存到项目记忆中。记录:启动Metro的命令、构建/运行应用的命令,以及任何所需的环境设置。
3.4 When to Reinstall vs Refresh
3.4 何时重新安装 vs 刷新
| Situation | Action |
|---|---|
| JS/React only changed | Use |
Native code or | Rebuild: |
| |
| App needs reinstalling from .app path | Use |
| Persistent native build errors | Full clean + reinstall (step 2 above). |
| 场景 | 操作 |
|---|---|
| 仅JS/React代码变更 | 使用 |
原生代码或 | 重新构建:执行 |
| 执行 |
| 需要从.app路径重新安装应用 | 使用 |
| 持续出现原生构建错误 | 完全清理 + 重新安装(上述第2步)。 |
3.5 Device Control
3.5 设备控制
| Action | Tool / Command |
|---|---|
| List devices | |
| Boot an iOS simulator | |
| Boot an Android emulator | |
| Launch an app | |
| Restart an app | |
| Open a URL / deep link | |
| Rotate device | |
| Stop simulator server | |
| Stop all simulator servers | |
For full simulator setup workflow, refer to the skill.
argent-ios-simulator-setup| 操作 | 工具 / 命令 |
|---|---|
| 列出设备 | |
| 启动iOS模拟器 | |
| 启动Android模拟器 | |
| 启动应用 | |
| 重启应用 | |
| 打开URL / 深度链接 | |
| 旋转设备 | |
| 停止模拟器服务器 | |
| 停止所有模拟器服务器 | |
完整的模拟器设置工作流,请参考技能。
argent-ios-simulator-setup4. Runtime Problems in the App
4. 应用运行时问题
4.1 Where to Look
4.1 排查方向
| Problem type | Tool / Where to look |
|---|---|
| JavaScript errors / logs | Use |
| React component hierarchy | Use |
| Visual state of the app | Use |
| Evaluate JS in the app | Use |
| Native crashes / native stack | |
| Build/runtime config | |
For comprehensive Metro debugging workflows (component inspection, console logs, JS evaluation), refer to the skill.
argent-metro-debugger| 问题类型 | 工具 / 排查位置 |
|---|---|
| JavaScript错误 / 日志 | 使用 |
| React组件层级 | 使用 |
| 应用视觉状态 | 使用 |
| 在应用中执行JS | 使用 |
| 原生崩溃 / 原生调用栈 | 执行 |
| 构建/运行时配置 | |
全面的Metro调试工作流(组件检查、控制台日志、JS执行),请参考技能。
argent-metro-debugger4.2 JS Console Logs (Log Registry)
4.2 JS控制台日志(日志注册表)
Logs are written to a flat log file on disk under . Use the log-registry → grep pattern instead of reading logs inline.
~/.argent/tmp/For the full workflow, flat entry format, and grep examples, see skill §5.
argent-metro-debugger日志会写入磁盘上目录下的扁平日志文件中。使用log-registry → grep模式,而非直接读取日志内容。
~/.argent/tmp/完整工作流、扁平条目格式和grep示例,请查看技能第5节。
argent-metro-debugger4.3 Do not try to use the DevMenu in React Native apps by default.
4.3 默认情况下请勿尝试使用React Native应用的DevMenu。
Use the argent tools instead.
请使用argent工具替代。
5. Testing the App
5. 测试应用
Check the result for test commands. For interactive UI testing with automatic screenshot verification, use the skill.
argent-environment-inspectorargent-test-ui-flow- Unit tests: Look for Jest in (
package.json,"test": "jest"config). Run:jestornpm test.yarn test - E2E: Look for Detox (or similar), or other E2E config. Dependencies:
.detoxrc.js,detox, and for iOS oftendetox-cli.applesimutils - UI flow testing: For interactive UI testing with automatic screenshot verification, refer to the skill.
argent-test-ui-flow
从结果中查看测试命令。如需带自动截图验证的交互式UI测试,请使用技能。
argent-environment-inspectorargent-test-ui-flow- 单元测试:在中查找Jest配置(
package.json、"test": "jest"配置)。运行:jest或npm test。yarn test - E2E测试:查找Detox配置(或类似文件),或其他E2E配置。依赖项:
.detoxrc.js、detox,iOS通常还需要detox-cli。applesimutils - UI流程测试:如需带自动截图验证的交互式UI测试,请参考技能。
argent-test-ui-flow
5.2 Running Tests (Typical)
5.2 运行测试(典型流程)
If the user's intent is ambiguous (run existing tests, write new tests, or find missing coverage), clarify before proceeding.
- Jest: or
npm test.npx jest - Detox (example):
- Build: (or debug).
detox build --configuration ios.sim.release - Run: .
detox test --configuration ios.sim.release - Ensure simulator is booted and not used by another process.
- Build:
若用户意图不明确(运行现有测试、编写新测试或查找测试覆盖率缺口),请先澄清。
- Jest:或
npm test。npx jest - Detox(示例):
- 构建:(或debug)。
detox build --configuration ios.sim.release - 运行:。
detox test --configuration ios.sim.release - 确保模拟器已启动且未被其他进程占用。
- 构建:
5.3 Agent Testing Checklist
5.3 代理测试检查清单
- Read and test config (Jest, Detox, etc.).
package.json - If E2E: confirm simulator/device and build config.
- If unclear: clarify whether to use existing workflows or write new tests.
- 已阅读和测试配置(Jest、Detox等)。
package.json - 若为E2E测试:确认模拟器/设备和构建配置。
- 若不明确:澄清是使用现有工作流还是编写新测试。
Quick Reference: Tools & Commands
快速参考:工具与命令
| Goal | Tool / Command |
|---|---|
| Check port 8081 | |
| Kill Metro | |
| Start Metro | |
| Start Metro (reset cache) | |
| Run iOS app | |
| Run Android app | |
| List devices | |
| Boot a device | |
| Take screenshot | |
| Describe screen (a11y tree) | |
| Read JS console logs | |
| Reload JS bundle | |
| Check Metro status | |
| Inspect React component tree | |
| Run JS in app | |
| iOS native logs | |
| Android native logs | |
| Clean + reinstall (nuclear) | See §3.1 step 3 |
| 目标 | 工具 / 命令 |
|---|---|
| 检查端口8081 | |
| 终止Metro进程 | |
| 启动Metro | |
| 启动Metro(重置缓存) | |
| 运行iOS应用 | |
| 运行Android应用 | |
| 列出设备 | |
| 启动设备 | |
| 截图 | |
| 描述屏幕(无障碍树) | |
| 读取JS控制台日志 | |
| 重新加载JS bundle | |
| 检查Metro状态 | |
| 检查React组件树 | |
| 在应用中执行JS | |
| iOS原生日志 | |
| Android原生日志 | |
| 完全清理 + 重新安装(终极方案) | 见第3.1节第3步 |
Related Skills
相关技能
| Skill | When to use |
|---|---|
| Initial iOS simulator boot and connection setup |
| Initial Android emulator boot and connection setup |
| Tapping, swiping, typing, hardware buttons, gestures on the simulator/emulator |
| Full Metro CDP debugging: component inspection, console logs, JS evaluation |
| Profiling performance, finding re-render issues, CPU hotspots |
| Interactive UI testing with automatic screenshot verification after each action |
Ask the user before running tests: confirm which test suite (unit, E2E, or both), whether to use existing CI commands, and whether they want you to run existing tests, write new ones, or explore test cases yourself.
| 技能 | 使用场景 |
|---|---|
| iOS模拟器初始启动和连接设置 |
| Android模拟器初始启动和连接设置 |
| 在模拟器/设备上执行点击、滑动、输入、硬件按键操作、手势 |
| 完整的Metro CDP调试:组件检查、控制台日志、JS执行 |
| 性能分析、查找重渲染问题、CPU热点 |
| 交互式UI测试,每次操作后自动截图验证 |
运行测试前请询问用户:确认测试套件(单元测试、E2E测试或两者都要)、是否使用现有CI命令,以及是运行现有测试、编写新测试还是自行探索测试用例。