|
| 1 | +Guidance for AI coding agents (Copilot, Cursor, Aider, Claude, etc.) working in this repository. Human readers are welcome, but this file is written for tools. |
| 2 | + |
| 3 | +### Repository purpose |
| 4 | + |
| 5 | +This repo hosts Stream's Node.js SDK in TypeScript. It provides: |
| 6 | +• A comprehensive client for Stream's Chat, Video, and Feeds (v3) APIs |
| 7 | +• Server-side SDK for building chat, video calling, and activity feeds |
| 8 | +• Support for all Stream services: Chat, Video, Feeds (v3), and Moderation |
| 9 | + |
| 10 | +Agents should prioritize backwards compatibility, API stability, and high test coverage when changing code. |
| 11 | + |
| 12 | +### Tech & toolchain |
| 13 | + |
| 14 | +• Language: TypeScript (Node.js) |
| 15 | +• Package managers: Yarn (primary) |
| 16 | +• Minimum Node.js: 18.0.0 or newer (see package.json engines) |
| 17 | +• Runtime targets: Node.js 18+, Node.js 20+, Node.js 22+, Bun 1+ |
| 18 | +• CI: GitHub Actions (assume PR validation on build + tests + lint) |
| 19 | +• Linters & docs: ESLint + Prettier |
| 20 | + |
| 21 | +### Project layout (high level) |
| 22 | + |
| 23 | +src/ |
| 24 | +gen/ # Generated API clients and models |
| 25 | +chat/ # Chat API client and models |
| 26 | +video/ # Video API client and models |
| 27 | +feeds/ # Feeds API client and models |
| 28 | +moderation/ # Moderation API client and models |
| 29 | +common/ # Common API utilities |
| 30 | +models/ # API request and response models for all supported products |
| 31 | +utils/ # Utility functions (token creation, rate limiting) |
| 32 | +StreamClient.ts # Main client class |
| 33 | +StreamChatClient.ts # Chat-specific client |
| 34 | +StreamVideoClient.ts # Video-specific client |
| 35 | +StreamFeedsClient.ts # Feeds-specific client |
| 36 | +StreamModerationClient.ts # Moderation-specific client |
| 37 | +**tests**/ # Test files |
| 38 | +\*.test.ts # Test files for each module |
| 39 | + |
| 40 | +Use the closest folder's patterns and conventions when editing. |
| 41 | + |
| 42 | +### Local setup (Node.js) |
| 43 | + |
| 44 | +1. Ensure Node.js 18+ is installed |
| 45 | +2. Install dependencies: `yarn install` |
| 46 | +3. Build the project: `yarn build` |
| 47 | +4. Run tests: `yarn test` |
| 48 | + |
| 49 | +### Alternative: Package consumer check |
| 50 | + |
| 51 | +If you need to validate as a package consumer: |
| 52 | + |
| 53 | +1. Create a throwaway sample project. |
| 54 | +2. Add to package.json: |
| 55 | + |
| 56 | +```json |
| 57 | +{ |
| 58 | + "dependencies": { |
| 59 | + "@stream-io/node-sdk": "^0.6.5" |
| 60 | + } |
| 61 | +} |
| 62 | +``` |
| 63 | + |
| 64 | +3. Install and test the integration. |
| 65 | + |
| 66 | +### Available Scripts |
| 67 | + |
| 68 | +Common npm/yarn scripts in this repo include: |
| 69 | +• `build` - Build the TypeScript project to dist/ |
| 70 | +• `test` - Run tests with Vitest |
| 71 | +• `test:bun` - Run tests with Bun |
| 72 | +• `lint` - Run ESLint |
| 73 | +• `lint:fix` - Run ESLint with auto-fix |
| 74 | +• `prettier:fix` - Run Prettier to format code |
| 75 | +• `generate:open-api` - Regenerate API clients from OpenAPI specs |
| 76 | + |
| 77 | +Agents should check package.json scripts before running commands. |
| 78 | + |
| 79 | +### Build & test commands (CLI) |
| 80 | + |
| 81 | +Use yarn/npm for day-to-day work; use CLI for CI parity & agent automation. |
| 82 | + |
| 83 | +Build the project: |
| 84 | + |
| 85 | +```bash |
| 86 | +yarn build |
| 87 | +``` |
| 88 | + |
| 89 | +Run all tests: |
| 90 | + |
| 91 | +```bash |
| 92 | +yarn test |
| 93 | +``` |
| 94 | + |
| 95 | +Run tests with Bun: |
| 96 | + |
| 97 | +```bash |
| 98 | +yarn test:bun |
| 99 | +``` |
| 100 | + |
| 101 | +Run linting: |
| 102 | + |
| 103 | +```bash |
| 104 | +yarn lint |
| 105 | +``` |
| 106 | + |
| 107 | +Format code: |
| 108 | + |
| 109 | +```bash |
| 110 | +yarn prettier:fix |
| 111 | +``` |
| 112 | + |
| 113 | +Linting & formatting |
| 114 | +• ESLint and Prettier are configured for this project. Run before committing: |
| 115 | + |
| 116 | +```bash |
| 117 | +yarn lint |
| 118 | +yarn prettier:fix |
| 119 | +``` |
| 120 | + |
| 121 | +• Respect .eslintrc and .prettierrc configurations. Do not suppress rules broadly; justify and scope exceptions. |
| 122 | +• The project uses lint-staged with Husky for pre-commit hooks. |
| 123 | + |
| 124 | +Commit / PR conventions |
| 125 | +• Use conventional commit format for commit messages. |
| 126 | +• Keep PRs small and focused; include tests. |
| 127 | +• Follow the project’s “zero warnings” policy—fix new warnings and avoid introducing any. |
| 128 | +• Ensure public API changes include docs and migration notes. |
| 129 | + |
| 130 | +Testing policy |
| 131 | +• Add/extend tests in the **tests**/ folder with .test.ts suffix. |
| 132 | +• Cover: |
| 133 | +• Core API clients and models (StreamClient, StreamChatClient, etc.) |
| 134 | +• Utility functions (token creation, rate limiting) |
| 135 | +• Generated API clients and their interactions |
| 136 | + |
| 137 | +Security & credentials |
| 138 | +• Never commit API keys or customer data. |
| 139 | +• Example code must use obvious placeholders (e.g., YOUR_STREAM_KEY). |
| 140 | +• If you add scripts, ensure they fail closed on missing env vars. |
| 141 | + |
| 142 | +Compatibility & distribution |
| 143 | +• Maintain compatibility with supported Node.js versions listed in package.json engines (Node.js 18+). |
| 144 | +• Don't introduce third-party deps without discussion. |
| 145 | +• Validate yarn integration and ensure the package works in both CommonJS and ES modules. |
| 146 | +• Test compatibility with Bun runtime when making changes. |
| 147 | + |
| 148 | +When in doubt |
| 149 | +• Mirror existing patterns in the nearest module. |
| 150 | +• Prefer additive changes; avoid breaking public APIs. |
| 151 | +• Ask maintainers (CODEOWNERS) through PR mentions for modules you touch. |
| 152 | + |
| 153 | +⸻ |
| 154 | + |
| 155 | +Quick agent checklist (per commit) |
| 156 | +• Build the project: `yarn build` |
| 157 | +• Run tests: `yarn test` |
| 158 | +• Run linting: `yarn lint` |
| 159 | +• Format code: `yarn prettier:fix` |
| 160 | +• Add/adjust tests |
| 161 | +• No new warnings or linting errors |
| 162 | + |
| 163 | +End of machine guidance. Edit this file to refine agent behavior over time; keep human-facing details in README.md and docs. |
0 commit comments