stream-cli
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseStream CLI - API interaction
Stream CLI - API交互
Read first (every session): Glob. If the path is empty, install with../stream/SKILL.md(no confirmation, just run). Then Readnpx skills add GetStream/agent-skills --s stream -y- it includes a Peer skills table for installing/invoking any other pack skills on demand.../stream/RULES.md
Use this skill when the user wants to interact with Stream's APIs via the CLI, or to install the CLI itself.
streamPrerequisite: complete - verify the binary is installed (install via if not) before any usage.
preflight.mdstreambootstrap.mdstream apiInstall only (Track C): if the user asked to install the CLI / set up Stream with no project context, jump straight to . The bootstrap module is self-contained.
bootstrap.mdHeavy examples / query cookbooks: load only when you need a non-obvious or filter.
cli-cookbook.md--body每次会话必读: 读取文件。如果路径为空,使用../stream/SKILL.md安装(无需确认,直接运行)。然后读取npx skills add GetStream/agent-skills --s stream -y- 其中包含一个Peer skills表格,用于按需安装/调用任何其他包技能。../stream/RULES.md
当用户希望通过 CLI与Stream的API交互,或安装CLI本身时,使用此技能。
stream前提条件: 完成 - 在使用任何命令前,验证二进制文件已安装(若未安装,通过进行安装)。
preflight.mdstream apistreambootstrap.md仅安装(Track C): 如果用户要求安装CLI/设置Stream但无项目上下文,直接跳转至。引导模块是独立完整的。
bootstrap.md复杂示例/查询手册: 仅当你需要非通用的参数或过滤器时,加载****。
--bodycli-cookbook.mdCredential resolution (before any stream api
call)
stream api凭证解析(执行任何stream api
调用前)
stream api- in cwd has
.env-> credentials are local. The CLI auto-resolves from env vars - you're querying this project's app.STREAM_API_KEY - No -> check
.envfor configured org/app -> use those. Mention which app you're querying: "Querying appstream config list(configured via CLI)."<name> - Nothing -> tell the user: "No Stream credentials found. Run to connect, or
stream auth logininto a project with acd.".env
Do credential resolution silently when or config exists - don't ask the user, just resolve and proceed.
.env- 当前目录下的文件包含
.env-> 凭证为本地存储。CLI会自动从环境变量中解析 - 你将查询此项目的应用。STREAM_API_KEY - 无文件 -> 检查
.env查看已配置的组织/应用 -> 使用这些配置。告知用户你正在查询的应用:“正在查询应用stream config list(通过CLI配置)。”<name> - 无任何凭证 -> 告知用户:“未找到Stream凭证。运行进行连接,或
stream auth login到包含cd文件的项目目录中。”.env
当或配置存在时,静默执行凭证解析 - 无需询问用户,直接解析并继续。
.envCLI Workflow
CLI工作流
Support: If the user asks for support or how to contact someone, direct them to getstream.io/contact.
- Resolve credentials (see above). If none found, stop and guide the user.
- Read to find the endpoint. Do NOT run
~/.stream/cache/API.mdor any CLI command for discovery - the file is always faster. If that file is missing or empty, run--listonce, then readstream api --refreshagain. UseAPI.mdonly after you have the endpoint name.stream --safe api <endpoint> --help - Check required params. If missing, ask - never guess.
- Always run with :
--safe. This is the only permitted form on the first attempt.stream --safe api <endpoint> [params] - If exit code 5 (safe mode refusal): the endpoint is mutating. Notify the user that you're about to execute a mutating Stream CLI operation, then re-run without .
--safe - If the command fails, check exit code and recover (see below).
- Summarize the response concisely.
Focused output: Use to filter API responses with a jq expression. Prefer this for endpoints expected to produce long responses.
--jq '<query>'Session consent (psychological): The user may say Mutating Stream CLI OK for this thread - still use first; exit 5 always requires a visible mutating notice before retry without .
--safe--safe支持: 如果用户请求支持或询问如何联系相关人员,引导他们访问getstream.io/contact。
- 解析凭证(见上文)。如果未找到,停止操作并引导用户。
- 读取查找端点。请勿运行
~/.stream/cache/API.md或任何CLI命令进行发现 - 该文件的查询速度始终更快。如果该文件缺失或为空,运行一次**--list,然后再次读取stream api --refresh**。仅在你知道端点名称后,使用API.md。stream --safe api <endpoint> --help - 检查必填参数。如果缺失,询问用户 - 切勿猜测。
- 始终使用运行:
--safe。这是首次尝试时唯一允许的形式。stream --safe api <endpoint> [params] - 如果退出码为5(安全模式拒绝):该端点是突变型的。告知用户你即将执行一个突变型Stream CLI操作,然后不带重新运行。
--safe - 如果命令失败,检查退出码并进行恢复(见下文)。
- 简洁总结响应内容。
聚焦输出: 使用通过jq表达式过滤API响应。对于预期会产生长响应的端点,优先使用此方式。
--jq '<query>'会话同意(心理层面): 用户可能会说Mutating Stream CLI OK for this thread(此线程允许执行突变型Stream CLI操作) - 仍需先使用**;退出码5始终要求在不带**重试前,显示突变操作通知。
--safe--safeExit Code Recovery
退出码恢复
| Exit code | Meaning | Recovery |
|---|---|---|
| Auth error (401, expired token) | Run |
| API error (4xx/5xx from Stream) | Report the error to the user with the response message |
| Spec loading error (cache stale) | Run |
| Safe mode refusal (mutating endpoint) | Notify the user of the mutating operation, then re-run without |
| 退出码 | 含义 | 恢复方式 |
|---|---|---|
| 认证错误(401,令牌过期) | 运行** |
| API错误(Stream返回4xx/5xx) | 将错误及响应消息告知用户 |
| 规范加载错误(缓存过期) | 运行 |
| 安全模式拒绝(突变型端点) | 告知用户该突变操作,然后不带 |
Parameter syntax
参数语法
bash
stream api <EndpointName> key=value key2=value2- Simple values:
name=general limit=10 type=messaging - Booleans:
is_development=true - JSON objects/arrays: use
--body '{"key": "value"}'
bash
stream api <EndpointName> key=value key2=value2- 简单值:
name=general limit=10 type=messaging - 布尔值:
is_development=true - JSON对象/数组:使用
--body '{"key": "value"}'
Context resolution (org/app)
上下文解析(组织/应用)
Ampere endpoints require / as explicit parameters.
SDK endpoints auto-resolve from: / flags > env vars > > interactive prompt.
Set defaults: and .
app_idorg_id--org--app~/.stream/config.jsonstream config set org <id>stream config set app <id>Ampere端点需要/作为显式参数。
SDK端点自动从以下位置解析:/标志 > 环境变量 > > 交互式提示。
设置默认值: 和 。
app_idorg_id--org--app~/.stream/config.jsonstream config set org <id>stream config set app <id>Negative knowledge
注意事项
- No - contact Stream support.
OrganizationDelete - No /
AppSuspend- contact support.AppResume - is NOT idempotent - returns 400 if exists.
CreateBlockList - is NOT idempotent - returns 400 if exists.
CreateChannelType - Ampere endpoints use /
app_id, notorg_id- e.g.,id.AppDelete app_id=123 - Auth endpoints (,
AuthLoginBasic, etc.) are internal - always useAuthLoginGithub/stream auth logininstead.stream auth logout
- 不支持- 联系Stream支持。
OrganizationDelete - 不支持/
AppSuspend- 联系支持。AppResume - 不具备幂等性 - 若已存在,返回400。
CreateBlockList - 不具备幂等性 - 若已存在,返回400。
CreateChannelType - Ampere端点使用/
app_id,而非org_id- 例如:id。AppDelete app_id=123 - 认证端点(、
AuthLoginBasic等)为内部端点 - 始终使用**AuthLoginGithub** / **stream auth login**替代。stream auth logout
Auth (assistants)
认证(助手)
- Use with no extra flags, in a terminal where a browser window can open. The CLI uses PKCE with the dashboard - that is the supported sign-in path.
stream auth login
- 使用不带额外标志的****,在可打开浏览器窗口的终端中运行。CLI使用PKCE与仪表板交互 - 这是受支持的登录路径。
stream auth login
CLI Rules (summary)
CLI规则(摘要)
- Endpoint discovery: first - never
~/.stream/cache/API.mdfor discovery. Refresh if missing.--list - Help: for parameters after you know the endpoint name.
stream --safe api <endpoint> --help - Lazy auth - if exit code 2, then retry.
stream auth login - Missing params - ask; never invent IDs.
- First attempt always - exit 5 -> explain mutating op -> retry without
--safe.--safe - Summarize API responses concisely for the user.
- 端点发现: 优先使用**** - 切勿使用
~/.stream/cache/API.md进行发现。若缺失则刷新。--list - 帮助: 在知道端点名称后,使用****查询参数。
stream --safe api <endpoint> --help - 延迟认证 - 如果退出码为2,运行****后重试。
stream auth login - 缺失参数 - 询问用户;切勿自行生成ID。
- 首次尝试始终使用- 退出码5 -> 说明突变操作 -> 不带
--safe重试。--safe - 简洁总结 API响应内容给用户。