cordierite

将支持Cordierite的React Native应用连接到你的机器,并通过应用注册的工具从终端驱动它——适用于代理、脚本等场景。

npx skills add https://github.com/callstackincubator/cordierite --skill cordierite

Cordierite

Cordierite is a CLI and host workflow for connecting to a Cordierite-enabled React Native app, discovering its registered tools, invoking those tools from the terminal, and ending the session cleanly after use.

Agent workflow

  1. Run cordierite session --json. The response includes data.sessions (each entry has session_id, status, endpoint info, etc.). If sessions is empty, no Cordierite host is registered for this machine (for this registry).
  2. If you need a new session for a device, follow Establish a session below. Record host.session_id from the host JSON—you must pass it to tools and invoke.
  3. After the user opens the deep link on the device and the app connects, confirm with cordierite session --session-id <session_id> --json until data.selected reflects an active connection (or re-check session --json and infer from the listed session).
  4. cordierite tools --session-id <session_id> --json — list tools registered in the app.
  5. cordierite tools --session-id <session_id> <tool-name> --json — inspect one tool’s input/output schema before calling it.
  6. cordierite invoke --session-id <session_id> <tool-name> --input '{"key":"value"}' --json — invoke the tool with JSON args.

Establish a session

Start the host with --json using the same TLS key and app URL scheme as the project (see Setup if you are wiring Cordierite into an app). The CLI generates the host certificate automatically from the resolved local IP. If the project does not already have a trusted host key, create one first with cordierite keygen in an interactive terminal and add the printed fingerprint to the app’s cliPins. If the default listen port is in use, add --port <port>.

cordierite host --tls-key /path/to/key.pem --scheme myapp --json

Run cordierite host in the background. It blocks; keep the foreground shell free for session, tools, and invoke.

From the host JSON output, use at least:

  • host.deep_link — full URL (e.g. myapp:///?cordierite=…) for the app to open.
  • host.session_id — pass this as --session-id to tools / invoke / session --session-id.

Then:

  1. Give the user the deep link (or QR from interactive host UI on a TTY) so they can open it on a device or simulator.
  2. Or open it yourself when you know the target (e.g. iOS Simulator xcrun simctl openurl booted '<url>', Android via adb, or device automation skills).

After the app opens the link and claims the session, poll cordierite session --session-id <session_id> --json (or session --json) until the session is active.

Terminate the connection

When the user wants to disconnect or stop Cordierite for that session: stop the matching background cordierite host process (end the job, SIGTERM, etc.). That tears down the host and the session. If several hosts run (e.g. different --port), stop the one that corresponds to the session_id you were using.

Declaring tools

The app must register tools before cordierite tools / cordierite invoke can do anything useful. Define schemas with Zod and register with registerTool:

import { registerTool } from "@cordierite/react-native";
import { z } from "zod";

const echoInput = z.object({
  value: z.unknown(),
});

const echoOutput = z.object({
  echoed: z.unknown(),
});

registerTool(
  {
    name: "echo",
    description: "Return the input unchanged",
    inputSchema: echoInput,
    outputSchema: echoOutput,
    handler: async (args) => ({ echoed: args.value }),
  },
);

Notes

  • Use --json for structured CLI output in agent flows.
  • cordierite keygen is the normal setup command for new host keys. It is interactive-only in v1: it writes a PEM private key and prints the exact sha256/... fingerprint the app should trust.
  • tools and invoke always require --session-id (the value from host.session_id or sessions[].session_id).
  • Prefer cordierite session --json first rather than assuming a session exists.
  • If sessions is empty or tools / invoke fail with connection or session errors, establish a session (host running, deep link opened on the correct device).
  • If the app registers no tools, cordierite tools returns an empty list.
  • You may run multiple cordierite host processes (e.g. different --port for different devices); use the session_id that belongs to the host you care about.

Setup

For project integration guidance, see setup.md.

来自 callstackincubator 的更多技能

agent-device
callstackincubator
通过基于快照的界面发现和选择器驱动的回放,自动化iOS和Android应用交互。支持iOS模拟器/设备和Android模拟器/设备,具备会话绑定自动化、多租户远程守护进程模式以及面向QA工作流的设备级隔离。核心命令包括:用于UI发现及元素引用的snapshot、用于交互操作的press/fill/scroll、用于应用生命周期管理的open/close、以及用于二进制部署的install/reinstall。附带日志记录、网络检查等实用工具……
official
dogfood
callstackincubator
系统性地在iOS/Android上使用agent-device探索和测试移动应用,以发现漏洞、用户体验问题及其他问题。在需要内部测试、质量保证等场景下使用。
official
react-devtools
callstackincubator
从agent-device检查和剖析React Native组件树。用于React Native性能、分析、属性、状态、钩子、渲染原因、缓慢…
official
react-devtools
callstackincubator
React DevTools CLI,供AI代理使用。当用户要求你在运行时调试React或React Native应用、检查组件属性/状态/钩子、诊断……时使用。
official
github
callstackincubator
通过gh CLI实现GitHub工作流自动化,涵盖拉取请求、堆叠式PR及仓库管理。提供堆叠式PR合并工作流:对首个PR进行压缩合并,随后对链中每个后续PR执行变基并更新基础分支。包含冲突检测与手动解决提示,防止多PR合并期间出现静默失败。覆盖gh CLI核心操作:PR创建、状态检查、压缩/变基合并及分支管理。通过依赖gh CLI优化低上下文使用场景...
official
github-actions
callstackincubator
适用于React Native iOS模拟器和Android模拟器云端构建的GitHub Actions工作流模式,支持可下载的构建产物。用于配置CI构建…
official
react-native-best-practices
callstackincubator
面向React Native应用的结构化性能优化参考,涵盖FPS、包体积、TTI和内存。包含9份JavaScript/React指南(性能分析、列表、动画、内存)、9份原生优化指南(Turbo Modules、线程、性能分析)和9份打包指南(摇树优化、代码拆分、体积分析)。每份参考采用混合格式,包含快速模式/命令、影响评级(关键/高/中)以及深度解析说明(含前置条件和常见...)
official
react-native-brownfield-migration
callstackincubator
提供一种增量采用策略,用于将原生 iOS 或 Android 应用迁移到 React Native 或 Expo,并使用 @callstack/react-native-brownfield 进行初始…
official